RN
Reactive Programming Library for TypeScript
glitch-less & hot Observable only RxJS
Usage
npm install rnjs
import { RN, interval } from 'rnjs'
const a: RN<number> = interval(1000, true);
a.subscribe( console.log );
features
-
glitch-less
- about "glitch"
- all tasks are processed by priority-queue
-
has initial value
- all RN always has initial value
- you can get the current value by
value
property
(like BehaviorSubject
in RxJS)
import { RN, interval } from 'rnjs'
const a: RN<number> = interval(1000, true).take(8);
a.subscribe( console.log );
setTimeout( () => console.log( a.value ), 3500 );
setTimeout( () => console.log( a.value ), 5500 );
-
hot-RN(Observable) only
- no cold/hot conversions are needed
- all subscriber of an RN gets the same value at the same time
-
is compatible with RxJS
- RN has interconversion methods (toObservable, fromObservable)
- RN has the same subscribe API as RxJS
-> can be used in Angular async pipe
without conversion to RxJS Observable
Coresspondence tables to RxJS
RN | RxJS v6 |
---|
interval | interval |
fromEvent | fromEvent |
fromPromise | from |
fromObservable | - |
manual | BehaviorSubject |
RN | RxJS v6 |
---|
combine | combineLatest |
merge | merge |
- | concat |
- | zip |
RN | RxJS v6 |
---|
debounce | debounceTime |
filter | filter |
flatMap | flatMap |
map | map |
mapTo | mapTo |
pairwise | pairwise |
pluck | pluck |
scan | scan |
skip | skip |
skipAlreadyAppeared | distinct |
skipUnchanged | distinctUntilChanged |
skipWhile | skipWhile |
switchMap | switchMap |
take | take |
takeWhile | takeWhile |
withLatest | withLatestFrom |
withTimestamp | timestamp |
- | startWith |