timer - 2

RxJS 5 timer

by Brian Troncone

HTML

<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>

JavaScript

/*
  timer takes a second argument, how often to emit subsequent values
  in this case we will emit first value after 1 second and subsequent
  values every 2 seconds after
*/
const sourceTwo = Rx.Observable.timer(1000, 2000);
//output: 0,1,2,3,4,5......
const subscribeTwo = sourceTwo.subscribe(val => console.log(val));