Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debounce() and throttle()’s selector argument has wrong return type #3204

Closed
mernen opened this issue Jan 1, 2018 · 4 comments · Fixed by Xenira/Shashki#66
Closed

debounce() and throttle()’s selector argument has wrong return type #3204

mernen opened this issue Jan 1, 2018 · 4 comments · Fixed by Xenira/Shashki#66

Comments

@mernen
Copy link

mernen commented Jan 1, 2018

Here’s the current signature for debounce():

export function debounce<T>(durationSelector: (value: T) => SubscribableOrPromise<number>): MonoTypeOperatorFunction<T> {

One thing that confused me is that it asks for your function to return a SubscribableOrPromise<number>. The documentation compounded my confusion ("A function (…) for computing the timeout duration for each source value”): is my selector supposed to return the number of milliseconds? Turns out the result of that observable/promise is completely discarded.

RxJS version: 5.5.6 (and, looking at the code, the next branch, too)

Additional information: throttle() has the same issue. Interestingly, audit() is correctly using SubscribableOrPromise<any>:

export function audit<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): MonoTypeOperatorFunction<T> {

@cartant
Copy link
Collaborator

cartant commented Jan 2, 2018

Regarding debounce, see #3164 and #3169. I will have a look at the throttle typings

@mernen
Copy link
Author

mernen commented Jan 2, 2018

Ah, that’s nice! Sorry, it completely forgot to search for past reports. My bad.

@cartant
Copy link
Collaborator

cartant commented Jan 2, 2018

No worries; you're right. throttle also uses number instead of any. I'll create another PR.

cartant added a commit to cartant/rxjs that referenced this issue Jan 2, 2018
cartant added a commit to cartant/rxjs that referenced this issue Jan 13, 2018
acutmore pushed a commit to youviewtv/rxjs-5 that referenced this issue Jan 23, 2018
* test(throttle): add typings tests

* fix(typings): relax throttle selector type

Closes ReactiveX#3204

(cherry picked from commit e83fda7)
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants