Function createOperatorFunction

  • Use this to create a complex pipeable operator. It is usually better style to compose existing operators than to create a brand new one, but when you need full control this can reduce some boilerplate.

    The supplied subscriber will act as a simple pass-through of all values, errors, and completion to destination. Modify it for your needs.

    A simple example, recreating the "map" operator:

    function map<I, O>(fn: (input: I) => O) {
    return createOperatorFunction<I, O>(
    (subscriber, destination) => {
    subscriber.next = (value) => {
    destination.next(fn(value));
    };
    },
    );
    }

    For a more complex example, check the source of skipAfter.

    Type Parameters

    Parameters

    • modifySubscriber: ((subscriber, destination) => void)
        • (subscriber, destination): void
        • Parameters

          Returns void

    Returns OperatorFunction<SourceType, DestinationType>