我在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]) => { ... });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。