RxJs来自vs的可观察对象 [英] RxJs Observable of vs from

查看:93
本文介绍了RxJs来自vs的可观察对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Observable.of Observable.from 参数格式之间的唯一区别是什么?像 Function.prototype.call Function.prototype.apply

Is the only difference between Observable.of and Observable.from the arguments format? Like the Function.prototype.call and Function.prototype.apply?

Observable.of(1,2,3).subscribe(() => {})
Observable.from([1,2,3]).subscribe(() => {})


推荐答案

不完全。将数组传递给 Observable.from 时,它与 Observable.of 之间的唯一区别是参数的方式是传递。

Not quite. When passing an array to Observable.from, the only difference between it and Observable.of is the way the arguments are passed.

然而, Observable.from 将接受参数


可订阅对象,Promise,类似Observable,Array,可迭代或类似数组的对象

a subscribable object, a Promise, an Observable-like, an Array, an iterable or an array-like object to be converted

Observable.of 没有类似的行为 - 它总是只接受值并且不执行任何转换。

There is no similar behaviour for Observable.of - which always accepts only values and performs no conversion.

这篇关于RxJs来自vs的可观察对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆