1.0.0 • Published 6 years ago
rxjs-to-stoppable v1.0.0
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
}
1.0.0
6 years ago