select select - 1 year ago 463
TypeScript Question

rxjs throttle this.durationSelector is not a function

I am trying to

ngrx store action updates events with the following code

import 'rxjs/add/operator/throttle'
import { Dispatcher, Store } from '@ngrx/store';
static get parameters() {
return [[Dispatcher]];
constructor(actions$) {

.filter(action => action.type === this.Actions[`LOAD_USERS_REQUEST`])
.throttle(1000 /* ms */)
.subscribe(() =>

this throws me an error

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

When I replace
.throttle(() => 1000)
it throws a different error that clearly shows throttle expects a function, just not the one that I provide. But I wonder why because the documentation states throttle expects a number value.

Answer Source

Documentation page you're referring on is related to RxJS 4. Since you're using Angular2, you're using RxJS 5.

Operator throttle() expects as argument an Observable or Promise.

Operator throttleTime() takes as argument time in miliseconds.

So you should use throttleTime(1000).

Note that using .throttle(() => 1000) is very different. You pass an anonymous function that returns 1000 instead of 1000 number directly. That's why it throws a different error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download