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.
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 anEffect
that will do this for us automatically. This is whereEventListenerEffectFactory
comes into place.It keeps track of all added listeners, and removes them when the effect is removed.