【发布时间】:2019-08-02 19:34:40
【问题描述】:
如何从 Promise 从 RxJS 5 迁移到 RxJS 6,同时保持输入正确?
RxJS 5,一切正常:
return Observable.fromPromise<SomeInterface>(somePromiseFn())
RxJS 6:
return from<SomeInterface>(somePromiseFn())
抱怨:
Type 'SomeInterface' does not satisfy the constraint 'ObservableInput<any>'.
Type 'SomeInterface' is not assignable to type 'ArrayLike<any>'.
所以如果我理解正确,它期望 from 将有一个序列,数组。但是 promise 可以返回任何对象?
【问题讨论】:
-
somePromiseFn()返回什么? -
你试过
from<Promise<SomeInterface>>(... -
您找到解决方案了吗?我也有同样的问题
标签: typescript rxjs rxjs6