Created
April 28, 2017 03:37
-
-
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
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 {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