docs(aio): add Observable and Rx docs (#21423)

PR Close #21423
This commit is contained in:
Jason Aden
2018-01-09 11:31:41 -08:00
committed by Alex Eagle
parent d100f1b187
commit 79656e7f96
28 changed files with 1301 additions and 0 deletions

View File

@ -0,0 +1,25 @@
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
// #docregion
import { pipe } from 'rxjs/util/pipe';
import { filter, map } from 'rxjs/operators';
const nums = Observable.of(1, 2, 3, 4, 5);
// Create a function that accepts an Observable.
const squareOddVals = pipe(
filter(n => n % 2),
map(n => n * n)
);
// Create an Observable that will run the filter and map functions
const squareOdd = squareOddVals(nums);
// Suscribe to run the combined functions
squareOdd.subscribe(x => console.log(x));
// #enddocregion