Skip to content

Instantly share code, notes, and snippets.

@B3nnyL
Created March 29, 2018 02:46
Show Gist options
  • Save B3nnyL/2913b3bba56179e9c0b2e01b003f322f to your computer and use it in GitHub Desktop.
Save B3nnyL/2913b3bba56179e9c0b2e01b003f322f to your computer and use it in GitHub Desktop.
Rxjs-playground
//Click monster
var button = document.querySelector('button');
Rx.Observable.fromEvent(button, 'click')
.scan(count => count + 1, 0)
.subscribe(count => console.log(`Clicked ${count} times`));
//click and pop
var button = document.querySelector('button');
Rx.Observable.fromEvent(button, 'click')
.subscribe(() => console.log('Clicked!'));
//get the style of paragraphy when hovering over it.
var para = document.querySelector('p');
Rx.Observable.fromEvent(para, 'mouseover')
.subscribe(() => console.log(para.style.getPropertyValue('font-size')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment