Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 28, 2017 03:37
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/9c49f120323ac79e0c1dec456758ed05 to your computer and use it in GitHub Desktop.
Save Ibro/9c49f120323ac79e0c1dec456758ed05 to your computer and use it in GitHub Desktop.
RxJS - Sum numbers from 0 to 4 - Scan- Coding Blast - www.codingblast.com
import {Observable} from 'rxjs';
console.time('timer');
let source = Observable
.interval(100) // interval starts from 0
.take(4)
.scan((acc, val) => acc + val);
source.subscribe((value) => {
console.timeEnd('timer');
console.log('in next. Value: ', value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment