RxJS find() Conditional OperatorRxJS find() operator is a conditional operator that returns only the first value emitted by the source observable as an output when it meets some specific conditions. It finds the first value that meets some test conditions and emits that. In other words, we can say that the RxJS find() operator is used to return the observable when the first value of the source observable meets the condition for the predicate function taken as input. Syntax:Following is the syntax of the RxJS find() conditional operator: Or Parameter Explanation
Return valueThe RxJS find() operator returns an observable when the first value of the source observable meets with the condition for the predicate function taken as input. Let us see some examples of the RxJS find() operator to understand it clearly. Example 1Output: After executing the above example, you will see the following result: In the above example, you can see that when it gets the first value satisfying the condition form the following list: list1 = of(11, 22, 33, 44, 55, 66, 77, 88, 99); Then, it has emitted that value as an output. Example 2 (Find click inside a box, repeat when the click occurs outside of box)Output: After executing the above example, you will see the following result: When you click inside the box, you have got the following output:
Next TopicRxJS Operators
|