There is also an operator called repeatWhen
. Rather than buffering and replaying
the sequence from the source Observable, it resubscribes to and mirrors the source
Observable, but only conditionally.
It decides whether to resubscribe and remirror the source Observable by passing that
Observable’s termination notifications (error or completed) to a notification handler as
void
emissions. This notification handler acts as an Observable operator, taking
an Observable that emits these void
notifications as input, and returning an
Observable that emits void
items (meaning, resubscribe and mirror the source
Observable) or terminates (meaning, terminate the sequence emitted by
repeatWhen
).
repeatWhen
operates by default on the trampoline
Scheduler. There is also a variant that allows you to set the Scheduler by
passing one in as a parameter.