RxJS for Beginners
RxJS helps manage async streams in Angular and other frameworks.
Create an Observable
import { Observable } from 'rxjs';
const obs = new Observable(sub => {
sub.next('Hello');
sub.next('World');
sub.complete();
});
obs.subscribe(console.log);
Use Operators
import { of } from 'rxjs';
import { map, filter } from 'rxjs/operators';
of(1, 2, 3).pipe(
filter(x => x > 1),
map(x => x * 2)
).subscribe(console.log); // 4, 6
Conclusion
RxJS makes handling async data and complex events easier.