who will it prevent from using its Observer method...
# rx
o
who will it prevent from using its Observer methods
a
Without it you could do
Copy code
(foo.commands as PublishSubject).onNext(command)
But this way that's not possible
☝️ 1
o
meaning I could access that class’
commands
variable and cast it as a PublishSubject and from there call onNext on it
this way only this class can do that
a
To be precise, this class also can't do
commands as PublishSubject
, but it has access to
commandsSubject
, so in that sense yes
👍🏻 1
c
The way i see it is allowing whoever accesses the property can only use the observable functions, meaning it can only listen to emissions, without it outside classes would have the capability to emit which might have pretty bad side effects
👍🏻 1