mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
b43f8bc7d3
PR Close #22573
21 lines
303 B
TypeScript
21 lines
303 B
TypeScript
|
|
import { Observable, of } from 'rxjs';
|
|
|
|
// #docregion
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
const nums = of(1, 2, 3);
|
|
|
|
const squareValues = map((val: number) => val * val);
|
|
const squaredNums = squareValues(nums);
|
|
|
|
squaredNums.subscribe(x => console.log(x));
|
|
|
|
// Logs
|
|
// 1
|
|
// 4
|
|
// 9
|
|
|
|
// #enddocregion
|