• EventListenerEffectFactory Ensures structured concurrency is honored by automatically removing HTMLElement event listeners when execution of the associated Task finishes.

    We want to make sure we remove listeners once the thread has finished running, instead of achieving this by manually removing events when AbortSignal.aborted on the outside, we can introduce an Effect that will do this for us automatically. This is where EventListenerEffectFactory comes into place.

    It keeps track of all added listeners, and removes them when the effect is removed.

    Parameters

    Returns {
        effect: {
            events: {
                subscribe: (<Ctx, Element_1, EventKey>(context, element, event, subscriber) => Unsubscribe);
            };
        };
        removeEffect?: (() => void);
    }

    • effect: {
          events: {
              subscribe: (<Ctx, Element_1, EventKey>(context, element, event, subscriber) => Unsubscribe);
          };
      }
      • events: {
            subscribe: (<Ctx, Element_1, EventKey>(context, element, event, subscriber) => Unsubscribe);
        }
        • subscribe: (<Ctx, Element_1, EventKey>(context, element, event, subscriber) => Unsubscribe)
            • <Ctx, Element_1, EventKey>(context, element, event, subscriber): Unsubscribe
            • Type Parameters

              • Ctx extends ExecutionContext<any, any, Ctx>

              • Element_1 extends EventTarget<Element_1>

              • EventKey extends string | number | symbol

              Parameters

              • context: Ctx
              • element: Element_1
              • event: EventKey
              • subscriber: EventSubscriber<Ctx, Element_1, EventKey>

              Returns Unsubscribe

    • Optional removeEffect?: (() => void)
        • (): void
        • Returns void

Generated using TypeDoc