What is RxJS
**A utility library for streams of data
Javascript version of ReactiveX API to handle observable streams
Fundamentals of RxJS
const myObservable = fromEvent(button, 'click');
Creating a observable from an event
Creating a observable using create()
const dataSource = of(1, 2, 3, 4, 5);
const hello = Observable.create(function(observer) {
observer.next('Hello');
observer.next('World');
observer.complete();
});
Creating a observable using of creation operator
Creating Observables
Subscription of Observables
const myObservable = fromEvent(button, 'click');
const subscription1 = myObservable.subscribe(event => console.log(event));
const subscription1 = myObservable.subscribe(event => console.log(event));
Un-subscription of Observables
const myObservable = fromEvent(button, 'click');
const subscription = myObservable.subscribe(event => console.log(event));
const secondSubscription = myObservable.subscribe(event => console.log(event));
// clean up with unsubscribe
subscription.unsubscribe();
secondSubscription.unsubscribe();
Operators
Real-world example of operators
Useful links