'of' vs 'from' operator

后端 未结 7 2129
栀梦
栀梦 2020-11-29 17:18

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

7条回答
  •  忘掉有多难
    2020-11-29 17:34

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

    However, Observable.from will accept an argument that is

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

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

提交回复
热议问题