rxjs-to-stoppable
v1.0.0
Published
Map any RxJS stream to a stoppable and resumable stream.
Downloads
3
Readme
rxjs-to-stoppable
Install
yarn add rxjs-to-stoppable
Usage
const { stream$, start, stop } = makeStoppable$$(interval(400));
setTimeout(() => {
stop();
}, 1200);
setTimeout(() => {
start();
}, 3000);
stream$.subscribe(() => {
// Will only emit in [0-1200] and [3000+]
});
Interactive RxViz demo : https://rxviz.com/v/xOv3BYzJ
API
Input :
- stream$: RxJS stream (required)
- startOnSubscribe: boolean (optional, default = true)
Output :
{
stream$: Observable,
start: () => void,
stop: () => void
}