之间唯一的区别是Observable.of
and Observable.from
参数格式?像Function.prototype.call
and Function.prototype.apply
?
Observable.of(1,2,3).subscribe(() => {})
Observable.from([1,2,3]).subscribe(() => {})
重要的是要注意之间的区别of
and from
当传递类似数组的结构(包括字符串)时:
Observable.of([1, 2, 3]).subscribe(x => console.log(x));
将立即打印整个数组。
另一方面,
Observable.from([1, 2, 3]).subscribe(x => console.log(x));
1 by 1 打印元素。
对于字符串,行为是相同的,但是是在字符级别。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)