RxJS中的等价物是什么Promise.resolve
?我知道我能做到,Observable.fromPromise(Promise.resolve(someValue));
但必须有一个更清洁的方式.
Observable.of正是您所寻找的(请参阅此插件):
// You might need to add this import in RxJS versions earlier than 5
import 'rxjs/add/observable/fromArray';
// ... or this line in RxJS 5+
import 'rxjs/add/observable/of';
if (me.groups) {
return Observable.of(me.groups);
}