I have a hot Observable
fed by a socket. I can use the pausable to pause the socket feed. But once I \'unpause\' the observable, I need to display the last valu
You don't even need pausable
to do this. (Note as well that you tagged RxJS5 but pausable
only exists in RxJS 4
). You simply need to convert your pauser
into a higher order Observable
:
var source = Rx.Observable.fromEvent(document, 'mousemove')
// Always preserves the last value sent from the source so that
// new subscribers can receive it.
.publishReplay(1);
pauser
// Close old streams (also called flatMapLatest)
.switchMap(active =>
// If the stream is active return the source
// Otherwise return an empty Observable.
Rx.Observable.if(() => active, source, Rx.Observable.empty())
)
.subscribe(/**/)
//Make the stream go live
source.connect();