How can I have a single-subscriber ReplaySubject
that:
- buffers all events received with
onNext()
until someone subscribes to it, - once someone subscribes to it, all buffered events are forwarded to the subscriber, erasing them from the
ReplaySubject
buffer (for performance reasons) and subsequent events are only forwarded to the subscriber (no more buffering), - if more than one observer subscribes to it, an exception is thrown,
- all buffered events given to the subject are ordered based on the time when each event was generated, and they are forwarded to the subscriber in that order during subscription?
Also, does this make sense? I think there would be good use cases for this subject, for cases when it forwards events from, e.g., a file system...