我有一个名为“在_auth服务中进行身份验证”的主题。
如果某些条件失败,我想处置/取消订阅它,以便在下一个值到达经过身份验证的主题时不会调用此订阅。
this.sub = this._auth.authenticated
.subscribe((loggedIn) => {
if (!loggedIn) {
this.sub.dispose(); // doesn't work because this.sub is null
this._location.replaceState('/');
this._auth.doLogout(); // emits value again in authenticated subject
}
});
Run Code Online (Sandbox Code Playgroud)
rxjs-5 的做法是什么?
| 归档时间: |
|
| 查看次数: |
2262 次 |
| 最近记录: |