Switch from remove callbacks to passing an AbortSignal
aborted after removal + accepting a removal promise.
#2756
Labels
Type: Breaking Change
For any feature request or suggestion that could reasonably break existing code
Type: Enhancement
For any feature request or suggestion that isn't a bug fix
Description
The idea is this: replace
onremove
andonbeforeremove
with:AbortSignal
parameter to component creation and viewsremoveReady
lifecycle "hook" that's a simple static promise (checking this is as simple as!= null
and we wouldn't need to call anything, simplifying our side)Old:
New:
Why
fetch
to WHATWG streams to evenaddEventListener
also accept abort signalsAbortController
andAbortSignal
- it's below 95%, but about 2% of those users are using ancient versions of modern browsers that most sites don't support anyways. It's also very easily polyfilled (and multiple polyfills exist already for it).Possible Implementation
Our remove logic would, instead of invoking remove callbacks, do the following:
removeReady
promise and this isn't being run from within a.then
handler, skip the vnode.ctrl.abort.bind(ctrl)
to run alongside lifecycle hooksCreation logic would create the above abort controller, and this would be stored with the vnode.
Open Questions
Do we really want to add a whole vnode field just to support this? Our vnodes are already rather bloated, and the vast majority of our memory usage and GC pressure comes from our vnodes.
I found in Chrome that a single
new AbortController()
call allocates 188 bytes each (60 for the controller, 128 for the signal). This combined with the slot (4 bytes) comes out to 192 bytes of overhead just for the abort controller alone. That doesn't sit well in light of #2755.The text was updated successfully, but these errors were encountered: