加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular2:如何去除Observable.combine最新的电话?

发布时间:2020-12-17 10:16:36 所属栏目:安全 来源:网络整理
导读:我在angular2应用程序中遇到了性能问题,因为我有一个很大的Observable.combineLatest(),其中有许多输入快速变化,我想要去掉回调调用: myData$= Observable.combineLatest( this.store.let(fromRoot.getFoo),this.store.let(fromRoot.getBar),this.store.let
我在angular2应用程序中遇到了性能问题,因为我有一个很大的Observable.combineLatest(),其中有许多输入快速变化,我想要去掉回调调用:
myData$= Observable.combineLatest(
  this.store.let(fromRoot.getFoo),this.store.let(fromRoot.getBar),this.store.let(fromRoot.getFoobar),this.store.let(fromRoot.getBarfoo),(foo,bar,foobar,barfoo) => {
     ...
  });

在事后调用去抖,例如Observable.combineLatest(…).debounceTime(300)是没用的,因为CPU密集型任务发生在仍然经常被调用的combineLatest回调中.

我想我必须结合另一个Observable,但我不知道该怎么做,有什么想法吗?

combineLatest方法的项目函数本质上是一个map运算符.你可以重新安排这样的事情:
myData$= Observable.combineLatest(
  this.store.let(fromRoot.getFoo),this.store.let(fromRoot.getBarfoo)
)
.debounceTime(300)
.map(([foo,barfoo]) => {
  ...
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读