Last active
April 24, 2020 12:56
-
-
Save NyaGarcia/953ffc30b265000beeecdf3fbeb3e217 to your computer and use it in GitHub Desktop.
Creating Observables with the fromEvent() function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fromEvent } from "rxjs"; | |
import { map } from 'rxjs/operators'; | |
// Creating an Observable from mouse clicks | |
const click$ = fromEvent<MouseEvent>(document, "click"); | |
// Creating an Observable from pressed keys | |
const keyPressed$ = fromEvent<KeyboardEvent>(document, "keydown"); | |
// Creating an Observable from scroll changes | |
const scroll$ = fromEvent<UIEvent>(document, "scroll"); | |
// Creating an Observable from copy action | |
const copie$ = fromEvent<ClipboardEvent>(document, "copy"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment