-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disconnected Events #678
Comments
Would you be able to use the |
Async event? We certainly don't want to add a synchronous event. That kind of DOM mutation events is exactly what we're trying to get rid of due to a high rate of security vulnerabilities caused by them and performance problems they cause. |
Yep, you can. But it would be nice not to have to imperatively unsubscribe (see the article) - plus that's only internal to the component. The framework already does this btw (emit an event in
Given |
|
👍. The exact timing is not so important for me. In terms of spec/implementation, would this be done more generically for all custom element reactions? |
If you're fine with the micro-task timing, you should just use https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver. It's implemented in all major browsers now.
No. We'd have to add it for each custom element reactions based on use cases. |
How would you use that exactly in this case, short of watching the entire document?
Just disconnected would be great. Doesn't really make sense to emit connected since no-one will/can be listening, it's commonly used for housekeeping, and it's very painful to try replicate with MutationObservers (i.e. compared to attributes where you just need to observe a single node). |
Just create a new mutation observer for each node you have to monitor? |
What if the parent of the node you're observing is detached? This is currently extremely painful to do in userland (and even then it's buggy due to batching) |
Oh I see. We probably need to add new options to observe |
Shall I raise this on whatwg/dom then? |
Filed whatwg/dom#533. |
Closing this in favor of the upstream feature request referenced above. |
Would it be possible to emit
disconnected
events on a node? I'd like to be able to do something like the following:(
node.on/once
is just simply creating a stream/promise of event(s) from the DOM element)This can obviously done with some wrapper but it would be nice if it didn't need that. Also I'm not sure if this can be done for all elements rather than just custom elements?
Related: Don't Unsubscribe
The text was updated successfully, but these errors were encountered: