Created
April 27, 2017 18:11
-
-
Save Ibro/a0b88390172c2f58ea1c17e5fceacd7d to your computer and use it in GitHub Desktop.
RxJS simple operators - 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'; | |
let numbers = [1, 2, 3, 4]; | |
let source = Observable | |
.from(numbers) | |
.map(n => n * 2) | |
.filter(n => n > 5) | |
.reduce((accumulator, currentValue) => accumulator + currentValue); | |
source.subscribe(value => { | |
console.log('next: ', value); | |
}, err => { | |
console.log('error: ', err); | |
}, () => { | |
console.log('complete'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment