RxJS fromEvent() Creation OperatorRxJS fromEvent() operator is a creation operator used to give the output as an observable used on elements that emit events, such as buttons, clicks, etc. In other words, we can say that the RxJS fromEvent() operator returns an observable that emits events of a specific type such as buttons, clicks, etc., when you target the given event. It creates an observable from DOM events, or Node.js EventEmitter events or others. Syntax:Following is the syntax of the RxJS fromEvent() creation operator: Or Parameter Explanation
Return valueThe RxJS fromEvent() operator returns an observable. Let us see some examples of the RxJS fromEvent() operator to understand it clearly. Example 1 (Emits clicks happening on the DOM document)Index.ts: Index.html: Output: After executing the above example, you will see the following result: Example 2 (Observable from mouse clicks)Index.ts: Index.html: Output: After executing the above example, you will see the following result:
Next TopicRxJS Operators
|