Skip to content

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

@mernen

Description

@mernen

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> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions