Update your RxJS BehaviorSubject if and only if conditoins are fullfilled
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');
$> npm i && npm test
Your project should have its own rxjs, it's omitted to avoid version conflicts.