【发布时间】:2020-07-24 08:37:37
【问题描述】:
我的 Angular 项目中有这个 RxJS 代码:
settingsService.getSetting('setting-name').pipe(
map((setting: SettingInterface) => {
// ...
return setting;
}),
tap((setting: SettingInterface) => this.settingService.save(setting)),
map((setting: SettingInterface) => {
// ...
})
);
在这段代码中,this.settingService.save(setting) 也是一个Observable,它没有被订阅。
如何在管道中启动这个 observable,等待它并继续?
重要:
-
save()observable 必须在之前的map()运算符之后开始 -
save()observable 的结果与管道无关,我想删除它 -
save()observable 必须在下一个map()运算符之前开始
有没有 RxJS 操作符可以做到这一点?
【问题讨论】:
-
像这样使用
concatMapconcatMap((setting: SettingInterface) => this.settingService.save(setting))
标签: angular rxjs observable rxjs6