Created
January 24, 2019 04:39
-
-
Save webhacking/4d2e18e15cc8439bad90c1848d99c83e to your computer and use it in GitHub Desktop.
RxJS Example 1
This file contains 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/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