Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created January 24, 2019 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webhacking/4d2e18e15cc8439bad90c1848d99c83e to your computer and use it in GitHub Desktop.
Save webhacking/4d2e18e15cc8439bad90c1848d99c83e to your computer and use it in GitHub Desktop.
RxJS Example 1
import {fromEvent} from 'rxjs/internal/observable/fromEvent';
const source$ = fromEvent(document.getElementById('hit-me'), 'click');
source$.subscribe((event: Event) => {
const currentClicked = ( event.currentTarget.getAttribute('number-of-clicked') ) ? event.currentTarget.getAttribute('number-of-clicked') : 1;
event.currentTarget.setAttribute('number-of-clicked', parseInt(currentClicked) + 1);
console.log(parseInt(currentClicked))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment