fromEvent
연산자(operator) 정의: fromEvent(target: EventTargetLike, eventName: string, selector: function): Observable
Turn event into observable sequence.
Examples
Example 1: Observable from mouse clicks
//create observable that emits click events
const source = Rx.Observable.fromEvent(document, 'click');
//map to string with given event timestamp
const example = source.map(event => `Event time: ${event.timeStamp}`)
//output (example): 'Event time: 7276.390000000001'
const subscribe = example.subscribe(val => console.log(val));
Related Recipes
Additional Resources
- fromEvent - Official docs
Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/observable/FromEventObservable.ts