Reputation: 1064
I have:
I would like to transform the source to an observable that makes sure the item is consumed exactly once by an observer. Observers that subscribe later should be only notified that the item has been consumed (completion event).
Expected behaviour:
1) Emission from the source before an observer subscribes
--O-|------> (source)
-----^-O-|-> (observer)
2) Emission from the source after an observer subscribes
------O-|-> (source)
--^---O-|-> (observer)
3) Subscription after item has been consumed
-O-|-------> (source)
-^-O-|-----> (observer1 - consumes the item)
------^-|--> (observer2 - is notified that the item has been consumed)
What is the simplest and most elegant way to achieve such behaviour?
Upvotes: 0
Views: 49