Angular & Signals (283 Qs)•Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)
What are the utility functions provided by RxJS?
The RxJS library also provides below utility functions for creating and working with observables.
- Converting existing code for async operations into observables
- Iterating through the values in a stream
- Mapping values to different types
- Filtering streams
- Composing multiple streams
Practical Code Example
typescript
// RxJS Pipeable Utility Operators:
import { of } from 'rxjs';
import { map, filter, catchError, debounceTime } from 'rxjs/operators';
const source$ = of(1, 2, 3, 4, 5);
source$.pipe(
filter(n => n % 2 !== 0), // 1, 3, 5
map(n => n * 10) // 10, 30, 50
).subscribe(val => console.log(val));