Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 27, 2017 18:11
Show Gist options
  • Save Ibro/a0b88390172c2f58ea1c17e5fceacd7d to your computer and use it in GitHub Desktop.
Save Ibro/a0b88390172c2f58ea1c17e5fceacd7d to your computer and use it in GitHub Desktop.
RxJS simple operators - Coding Blast - www.codingblast.com
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