Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 27, 2017 19:02
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 Ibro/42f6b3f6f0650e362697cc6eccbe8bd7 to your computer and use it in GitHub Desktop.
Save Ibro/42f6b3f6f0650e362697cc6eccbe8bd7 to your computer and use it in GitHub Desktop.
On Click -> Add stuff to html - Coding Blast - www.codingblast.com
import {Observable} from 'rxjs';
let btnFun = document.getElementById('btnFun');
let divMain = document.getElementById('divMain');
let clicksSource = Observable.fromEvent(btnFun, 'click');
clicksSource
.scan((s) => <number>s + 1, 0)
.forEach(number => addStuffToHtml(number));
function addStuffToHtml(number) {
let span = document.createElement('span');
span.innerText = ` ${number}`;
divMain.appendChild(span);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment