RxJS - 创建运算符 from
此运算符将从数组、类似数组的对象、承诺、可迭代对象或类似可观察对象创建一个可观察对象。
语法
from(input: ObservableInput): Observable
参数
input − 提供给此运算符的输入是一个可观察对象。
返回值 − 它返回一个可观察对象。
示例
import { from } from 'rxjs'; let arr = [2, 4, 6, 8 , 10]; let test = from(arr); test.subscribe(x => console.log(x));