angular – rxjs throttle this.durationSelector不是函数

前端之家收集整理的这篇文章主要介绍了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(() =>
    ...
  );
@H_403_3@这给我一个错误

@H_403_3@at ThrottleSubscriber.tryDurationSelector (throttle.js:80) TypeError:
this.durationSelector is not a function

@H_403_3@当我用.throttle(()=> 1000)替换.throttle(1000)时,它会抛出一个不同的错误,清楚地显示油门需要一个功能,而不是我提供的功能.但我想知道为什么因为文档说明油门需要一个数值.

@H_403_3@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. @H_403_3@运算符throttle()期望作为Observable或Promise的参数.

@H_403_3@运算符throttleTime()以毫秒为单位作为参数时间.

@H_403_3@所以你应该使用throttleTime(1000).

@H_403_3@请注意,使用.throttle(()=> 1000)是非常不同的.您传递一个匿名函数,该函数直接返回1000而不是1000数字.这就是它抛出不同错误的原因.

原文链接:https://www.f2er.com/angularjs/141473.html

猜你在找的Angularjs相关文章