我有这样的情况:
this._userService
.create(user)
.pipe(
switchMap(res => {
if (this.accountStore.accounts.length > 0) {
return this._accountsService.manageAccounts(
accounts,
res.idUser
);
} else return of();
})
)
.subscribe(
_ => {
this._router.navigate(["/app/main/user/"]);
},
() => (this.saving = false)
);
如果帐户高于0,则工作正常。但是如果它转到else块,return of()
就不会执行next()来导航到用户路由;
我做错了什么?
发布于 2019-02-22 05:09:59
您需要将一个值传递给of
以执行next operator或subscriber。在本例中,我只是将null
作为of(null)
传递
发布于 2019-02-22 04:02:18
与this answer相似,但由于版本不同,您需要使用of({}).pipe(take(1))
创建一个空对象observable并调用next。
对于您的代码:
...
} else return of({}).pipe(take(1));
...
https://stackoverflow.com/questions/54815229
复制相似问题