Yea, that may sound a bit ambitious but here is what I want to achieve:
I have class which holds my hot Observable
, it takes some time for class to prepare it correctly (create it in another place and obtain reference), so when another class asks for it, reference may be still null (causing nullpointer). What I'm trying to achieve is similiar to NullObject pattern: return empty observable (instead of null) which can be safely subscribed, and when Observable is created properly start emitting items.
The one way to solve it is to create PublishSubject
which acts as bridge between client classes and ObservableHolder class. PublishSubject reference is always returned to client, and when Observable
is ready it will just forward all events to subject. Is that a good solution? Or it can be done better?
Aucun commentaire:
Enregistrer un commentaire