You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per #53 (comment), we register many event handlers like addEventlistener('foo', this.bar = this.bar.bind(bar)), but rather than calling function bind we can use handleEvent and rather than calling removeEventListener a bunch, we can store an abort controller per-instance (e.g. with a private field) and abort during disconnectedCallback.
The pattern would look as follows:
classMyElementextendsHTMElement{
#ctl =newAbortController()connectedCallback(){this.input.addEventListener('foo',this,{signal: this.#ctl.signal})// many more events here...}handleEvent(event){if(event.type==='foo'&&event.currentTarget===this.input){// do things}}disconnectedCallback(){this.#ctl.abort()}}
The text was updated successfully, but these errors were encountered:
Per #53 (comment), we register many event handlers like
addEventlistener('foo', this.bar = this.bar.bind(bar))
, but rather than calling function bind we can usehandleEvent
and rather than callingremoveEventListener
a bunch, we can store an abort controller per-instance (e.g. with a private field) and abort duringdisconnectedCallback
.The pattern would look as follows:
The text was updated successfully, but these errors were encountered: