2020-09-28 17:56:59 +03:00
|
|
|
// #docplaster
|
|
|
|
/*
|
|
|
|
Because of how the code is merged together using the doc regions,
|
|
|
|
we need to indent the imports with the function below.
|
|
|
|
*/
|
|
|
|
/* tslint:disable:align */
|
2018-01-09 11:31:41 -08:00
|
|
|
// #docregion
|
2020-09-28 17:56:59 +03:00
|
|
|
import { of, pipe } from 'rxjs';
|
|
|
|
import { filter, map } from 'rxjs/operators';
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2020-09-28 17:56:59 +03:00
|
|
|
// #enddocregion
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2021-05-08 16:02:03 +02:00
|
|
|
export function docRegionDefault(console: Console) {
|
2020-09-28 17:56:59 +03:00
|
|
|
// #docregion
|
|
|
|
const nums = of(1, 2, 3, 4, 5);
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2020-09-28 17:56:59 +03:00
|
|
|
// Create a function that accepts an Observable.
|
|
|
|
const squareOddVals = pipe(
|
|
|
|
filter((n: number) => n % 2 !== 0),
|
|
|
|
map(n => n * n)
|
|
|
|
);
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2020-09-28 17:56:59 +03:00
|
|
|
// Create an Observable that will run the filter and map functions
|
|
|
|
const squareOdd = squareOddVals(nums);
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2020-09-28 17:56:59 +03:00
|
|
|
// Subscribe to run the combined functions
|
|
|
|
squareOdd.subscribe(x => console.log(x));
|
2018-01-09 11:31:41 -08:00
|
|
|
|
2020-09-28 17:56:59 +03:00
|
|
|
// #enddocregion
|
|
|
|
}
|