RxJS fromEventPattern() Creation OperatorRxJS fromEventPattern() operator is a creation operator that creates an observable input function or an arbitrary API that is later used for registering event handlers. In other words, we can say that the RxJS fromEventPattern() operator returns an observable that is used to register the event handler. The fromEventPattern() operator facilitates converting any API into an observable that supports registering handler functions for events. It is like fromEvent() operator, but far more flexible. We can easily handle all cases of fromEvent by fromEventPattern() operator. Syntax:Following is the syntax of the RxJS fromEventPattern() creation operator: Or Parameter Explanation
Return valueThe RxJS fromEventPattern() operator returns an observable when the event happens. For example, click, mouseover, etc. When an event happens, it emits the first parameter passed to the registered event handler. Alternatively, it emits whatever project function returns at that moment. Let us see some examples of the RxJS fromEventPattern() 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 whenever you click on the "Click me" button, DOM MouseEvent object is logged. Example 2Output: After executing the above example, you will see the following result:
Next TopicRxJS Operators
|