Transformation Operators
Transformation operators are used to transform and process data within the RxJS pipeline. By transforming values into new forms, they allow for more flexible and powerful control over reactive data flow.
List of Operators
◾ Simple Value Transformations
| Operator | Description |
|---|---|
| map | Apply a transformation function to each value |
◾ Accumulation
| Operator | Description |
|---|---|
| scan | Cumulatively generate values |
| reduce | Output only the final accumulated result |
◾ Pair and Grouping
| Operator | Description |
|---|---|
| pairwise | Process two consecutive values in pairs |
| groupBy | Group values based on a key |
◾ Asynchronous Transformation
| Operator | Description |
|---|---|
| mergeMap | Transform each value into an Observable and merge in parallel |
| switchMap | Switch to the latest Observable |
| concatMap | Execute each Observable sequentially |
| exhaustMap | Ignore new inputs while executing |
| expand | Recursively expand results |
◾ Batch Processing
| Operator | Description |
|---|---|
| buffer | Batch values at the timing of another Observable |
| bufferTime | Batch values at regular intervals |
| bufferCount | Batch values by specified count |
| bufferWhen | Buffering with dynamically controlled end conditions |
| bufferToggle | Buffering with independent control of start and end |
| windowTime | Split into sub-Observables at regular intervals |
Practical Transformation Patterns
In real-world applications, the following processing is possible by combining transformation operators:
- Input validation and feedback
- Optimal control of asynchronous API requests
- Data shaping, aggregation, and normalization
- Batch processing and grouping of event streams
👉 For more information: Practical Transformation Patterns
🚨 Notes
To avoid common mistakes when using transformation operators, see also:
- Side effects in map - Use
mapas a pure function - Inappropriate operator selection - Proper use of higher-order operators