Function debounceIf

  • Debounce values on the stream if the predicate returns true.

    marble

    Examples:

    Example 1

    debounceTimeInMs: don't matter in this example predicate: () => false

    source: 1-2-3|
    result: 1-2-3|

    Example 2

    10ms equals 1 frame debounceTimeInMs: 10 predicate: () => true

    source: 1-2-3|
    result: -1-2-3|

    Example 3 Debounce only on even values

    10ms equals 1 frame debounceTimeInMs: 10 predicate: (_, a) => a % 2 === 0

    source: 1-2-(3|)
    result: 1--2(3|)

    Type Parameters

    • T

    Parameters

    • debounceTimeInMs: number

      time to debounce in milliseconds

    • predicate: ((previous, last) => boolean)

      called with previous and last value, when evaluates to true debounce

        • (previous, last): boolean
        • Parameters

          • previous: undefined | T
          • last: T

          Returns boolean

    • Optional scheduler: SchedulerLike

      the scheduler

    Returns ((source) => Observable<undefined | T>)

      • (source): Observable<undefined | T>
      • Parameters

        • source: Observable<T>

        Returns Observable<undefined | T>

Generated using TypeDoc