1.0.1 • Published 5 years ago
rx-conditional-next v1.0.1
rx-conditoinal-next
Update your RxJS BehaviorSubject if and only if conditoins are fullfilled
Usage
For extended excamples, see main.spec.ts
const bs = new BehaviorSubject<any>('Hello');
conditionalNext(bs, 'World'); // => bs.value === 'World'
conditionalNext(bs, 'World 2', (newVal, prevVal) => newVal !== prevVal); // => bs.value === 'World'
conditionalNext(bs, 'World 2'); // no change, bs.value still === 'World 2'
conditionalNext(bs, 'World 3').onNext(()) => 'tell med what to do').onStop(() => 'is not called');
conditionalNext(bs, 'World 3').onNext(()) => 'is not called').onStop(() => 'tell med what to do');
Test
$> npm i && npm test
Dependencies
Your project should have its own rxjs, it's omitted to avoid version conflicts.