小编Car*_*tti的帖子

避免在 Angular 2+ 中嵌套订阅?

我有两个端点:

  • 1 个端点来获取当前用户的登录信息。
  • 1 个端点来获得此用户的授权。

其实我用:

this.user
  .subscribe((e) => {
     this.grants.get(e)
        .subscribe((x) => {
            console.log(x)
         })
  })
Run Code Online (Sandbox Code Playgroud)

但这是 Angular 2+/RxJS 的反模式。

我想知道如何按照 Angular/RxJS 最佳实践执行此操作。

谢谢

rxjs angular

6
推荐指数
1
解决办法
687
查看次数

标签 统计

angular ×1

rxjs ×1