- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Creation Operator fromEventPattern
This operator will create an observable from the input function that is used to register event handlers.
Syntax
fromEventPattern(addHandler_func: Function): Observable
Parameters
addHandler_func − The argument given is addHandler_func, this will be attached to the actual event source.
Return value
Returns an observable when the event happens, for example, click, mouseover, etc.
Example
import { fromEventPattern } from 'rxjs'; function addBtnClickHandler(handler) { document.getElementById("btnclick").addEventListener('click', handler); } const button_click = fromEventPattern(addBtnClickHandler); button_click.subscribe( x => console.log( "ClientX = "+ x.clientX + " and ClientY="+ x.clientY ) );
Output
Advertisements