RxJS last() Filtering OperatorRxJS last() operator is a filtering operator that emits only the last value or the last value that meets some specified condition emitted by the source observable. Syntax:Following is the syntax of the RxJS last() operator: Or Parameter Explanation
Return valueThe RxJS last() operator's return value is observable that emits the last value. Let us see some examples of the RxJS last() operator to understand it clearly. Example 1 (Emit last value in a given sequence)Output: After executing the above example, you will see the following result: Example 2 (Emit last value to meet a specific condition)Output: After executing the above example, you will see the following result: In the above example, you can see that the last given value is 9, but the condition is to emit the last even number; that's why it has emitted 8. Example 3 (Emit Last with default value)Output: After executing the above example, you will see the following result:
Next TopicRxJS Operators
|