rx-conditional-nextdeprecated

Update BehavioralSubject on fulfilled conditions only

Usage no npm install needed!

<script type="module">
  import rxConditionalNext from 'https://cdn.skypack.dev/rx-conditional-next';
</script>

README

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

gt; npm i && npm test

Dependencies

Your project should have its own rxjs, it's omitted to avoid version conflicts.