angular – rxjs throttle this.durationSelector不是函数
我试图用以下代码限制ngrx存储操作更新事件
import 'rxjs/add/operator/throttle' import { Dispatcher,Store } from '@ngrx/store'; ... static get parameters() { return [[Dispatcher]]; } constructor(actions$) { ... this.actions$ .filter(action => action.type === this.Actions[`LOAD_USERS_REQUEST`]) .throttle(1000 /* ms */) .subscribe(() => ... ); 这给我一个错误
当我用.throttle(()=> 1000)替换.throttle(1000)时,它会抛出一个不同的错误,清楚地显示油门需要一个功能,而不是我提供的功能.但我想知道为什么因为文档说明油门需要一个数值. https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/throttle.md
您在
https://github.com/Reactive-Extensions/RxJS上引用的文档页面与RxJS 4有关.由于您使用的是Angular2,因此您使用的是RxJS 5.
运算符 运算符 所以你应该使用throttleTime(1000). 请注意,使用.throttle(()=> 1000)是非常不同的.您传递一个匿名函数,该函数直接返回1000而不是1000数字.这就是它抛出不同错误的原因. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |