RxJS Augmented
RxJS operators and Browser API wrappers.
Installation
To install the latest version of rxjs-augmented, simply run:
npm install --save rxjs-augmented@latest
Of course it depends on rxjs, so install it if you haven't already:
npm install --save rxjs
API
Usage
Operators
These are pipeable rxjs operators
select
Will only emit if the mapped value is distinct from the previous. Useful for Observable state stores to avoid unnecessary rendering.
Example
;; const source$ = of1 2 2 1; source$; //2, 4, 1
Creation operators
These operators will let you create Observables from Browser APIs.
fromBlob
Internally this operator uses the FileReader
API. Pass it a File
or a Blob
and the readAs
method you desire (default will be readAsArrayBuffer
)
Example
;; //For Typescriptinterface HTMLInputEvent extends Event target: HTMLInputElement & EventTarget; const fileInput: HTMLInputElement = document; ;
fromWorker
Pass it an instance of Worker and internally it'll setup the listeners and post the initial message. Upon receiving the first message from the worker, it'll complete.
Example
//app.ts;;const button: HTMLButtonElement = document;
Observables
These are Observable wrappers for Browser APIs.
online
Observable of the browser's ability to connect to the network.
Example
; //Try connecting and disconnectingonline$; //true or false