Skip to content

Instantly share code, notes, and snippets.

@seysdev
Created May 21, 2019 23:36
Show Gist options
  • Save seysdev/415022593d59bc04ba3529e269618252 to your computer and use it in GitHub Desktop.
Save seysdev/415022593d59bc04ba3529e269618252 to your computer and use it in GitHub Desktop.
basic rxjs
/*
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