Understanding Operators
RxJS operators are a set of functions for transforming, composing, and controlling Observable data streams.
Operators are usually used in combination with several others, and this is where the "pipeline" comes in.
In RxJS, operators fall into the following categories
List of categories
- Transformation Operators
- Filtering Operators
- Combination Operators
- Utility Operators
- Conditional Operators
- Error Handling Operators
- Multicasting Operators
Each category contains a number of useful operators. See each category for details.
List of Operators
For a detailed description of each operator, click on the link to browse.
| Category | Operator | Description |
|---|---|---|
| Transformation | map | Converts each value |
| scan | Accumulate values and output intermediate results | |
| reduce | Accumulate all values and output only the final result | |
| pairwise | Processes two consecutive values in pairs | |
| groupBy | Grouping streams by key | |
| mergeMap | Parallel execution of asynchronous processing | |
| switchMap | Execute only the latest asynchronous processing (cancel older processing) | |
| concatMap | Execute asynchronous processes sequentially | |
| exhaustMap | Ignore new processes during execution | |
| expand | Recursively expand results | |
| buffer | Publish values in an array | |
| bufferTime | Publish values at specified time intervals | |
| bufferCount | Publish values in batches of specified number of values | |
| bufferWhen | Buffering with dynamically controlled end conditions | |
| bufferToggle | Buffering with independent control of start and end | |
| Filtering | filter | Only let through values that match the condition |
| take | Get only the first N values | |
| takeLast | Get the last N values | |
| takeWhile | Get values while the condition is met | |
| skip | Skip the first N values | |
| skipLast | Skip the last N values | |
| skipWhile | Skip values while the condition is satisfied | |
| skipUntil | Skip values until another Observable fires | |
| first | Get the first value or the first value satisfying a condition | |
| last | Get the last value or the last value that satisfies the condition | |
| elementAt | Get the value at a given index | |
| find | Find the first value that satisfies a condition | |
| findIndex | Get the index of the first value that satisfies the condition | |
| debounceTime | Issue the last value if no input is received for a specified time | |
| throttleTime | Pass through the first value and ignore the new value for the specified time | |
| auditTime | Issue last value after specified time | |
| audit | Issue last value with custom Observable to control period | |
| sampleTime | Sample latest value at specified time interval | |
| ignoreElements | Ignore all values and only pass through completions/errors | |
| distinct | Remove all duplicate values (output only unique values) | |
| distinctUntilChanged | Remove consecutive duplicate values | |
| distinctUntilKeyChanged | Detect only changes in specific properties of an object | |
| Combination (Pipeable) | concatWith | Join other Observables in sequence after completion |
| mergeWith | Combine multiple Observables simultaneously | |
| combineLatestWith | Combine the latest value of each Observable | |
| zipWith | Pair values in corresponding order | |
| raceWith | Adopt only the first Observable that fires | |
| withLatestFrom | Append other latest values to the main stream | |
| mergeAll | Flatten Higher-order Observables in parallel | |
| concatAll | Flatten Higher-order Observable in sequence | |
| switchAll | Switch to the latest Higher-order Observable | |
| exhaustAll | Ignore new Higher-order Observable during execution | |
| combineLatestAll | Combines the latest values of all internal Observables | |
| zipAll | Pair the corresponding values of each internal Observable | |
| Utility | tap | Perform side effects (e.g., log output) |
| finalize | Perform post-processing on completion or error | |
| delay | Delay all values for a specified time | |
| delayWhen | Delay each value dynamically with a separate Observable | |
| timeout | Issue an error if a value does not arrive within a specified time | |
| takeUntil | Retrieve values until another Observable issues a value | |
| retry | Retry up to specified number of times on error | |
| repeat | Repeat a specified number of times after completion | |
| startWith | Adds an initial value to the beginning of the stream | |
| toArray | Publish all values together in an array | |
| materialize | Convert a notification to a Notification object | |
| dematerialize | Convert the Notification object back to a normal notification | |
| observeOn | Use the scheduler to control when values are published | |
| subscribeOn | Use the scheduler to control when to start subscribing | |
| timestamp | Add a timestamp to each value | |
| Conditional | defaultIfEmpty | If no value is available, issue default value |
| every | Determine if all values satisfy the condition | |
| isEmpty | Determines if no value was issued | |
| Error Handling | catchError | Catch errors and perform fallback processing |
| retry | Retry a specified number of times on error | |
| retryWhen | Retry with custom conditions | |
| Multicasting | share | Share Observable among multiple subscribers |
| shareReplay | Cache the latest N values and replay them to new subscribers |