Function toggleMap

  • ⏯ Begins a new subscription to the mapped Observable, only if there is no current subscription.

    • Any current Subscription is terminated.
    • Use when cancelability is important, like a video player tapped both to start and stop.

    Example

    ```

    • const switch = new Subject();
    • const light = switch.pipe(toggleMap(() => new Observable(o => {
    • console.log('connected: true');
    • return () => console.log('connected: false');
    • }))).subscribe()
    • switch.next(); // connected: true
    • switch.next(); // connected: false
    • ```

    Type Parameters

    • T

    • R

    • S = R

    Parameters

    • workCreator: ((event: T) => ObservableInput<R>)

      The Observable-factory whose subscription is to be toggled *

        • (event: T): ObservableInput<R>
        • Parameters

          • event: T

          Returns ObservableInput<R>

    • Optional mapper: ((_: T, inner: R) => S)
        • (_: T, inner: R): S
        • Parameters

          • _: T
          • inner: R

          Returns S

    Returns OperatorFunction<T, S>

Generated using TypeDoc