Created
May 21, 2019 23:36
-
-
Save seysdev/415022593d59bc04ba3529e269618252 to your computer and use it in GitHub Desktop.
basic rxjs
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
| /* | |
| secuencia de eventos | |
| */ | |
| document.addEventListener('click', (e) => console.log('Clicked!', e.clientX)); | |
| /* | |
| usando rxjs | |
| */ | |
| import { fromEvent } from 'rxjs'; | |
| import { throttleTime, map } from 'rxjs/operators'; | |
| /* | |
| stream de eventos y uso de operators y escucha de cambios. | |
| */ | |
| fromEvent(document, 'click').pipe( | |
| throttleTime(1000), | |
| map(event => event.clientX * 2), | |
| ).subscribe((clientX) => console.log('Clicked!', clientX)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment