• Converts a plain event receiver registration function to AfterEvent keeper with a fallback.

    The event constructed by fallback will be sent to the registered first receiver, unless register function sends one.

    Type Parameters

    • TEvent extends any[]

      An event type. This is a list of event receiver parameter types.

    Parameters

    • register: ((this, receiver) => void)

      Generic event receiver registration function. It will be called on each receiver registration, unless the receiver's event supply is cut off already.

        • (this, receiver): void
        • Parameters

          • this: void
          • receiver: Generic<TEvent>

          Returns void

    • fallback: ((this) => TEvent) = AfterEvent$noFallback

      A function creating fallback event. When omitted, the initial event is expected to be sent by register function. A receiver registration would lead to an error otherwise.

        • (this): TEvent
        • Parameters

          • this: void

          Returns TEvent

    • cleanup: ((this, reason?) => void) = AfterEvent$noCleanup

      A function that will be called once all registered event supplies cut off.

        • (this, reason?): void
        • Parameters

          • this: void
          • Optional reason: unknown

          Returns void

    Returns AfterEvent<TEvent>

    An AfterEvent keeper registering event receivers with the given register function.

Generated using TypeDoc