📜  rxjs 地图 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:33.035000             🧑  作者: Mango

代码示例2
// RxJS v6+
import { from } from 'rxjs';
import { map } from 'rxjs/operators';

//emit (1,2,3,4,5)
const source = from([1, 2, 3, 4, 5]);
//add 10 to each value
const example = source.pipe(map(val => val + 10));
//output: 11,12,13,14,15
const subscribe = example.subscribe(val => console.log(val));