Ability to destroy and clean up the QwikLoader listeners (and resources) #282
Replies: 2 comments
-
|
Seems doable. The resumed container will need a As for qwikloader, it can only be removed when all the components have been resumed and re-rendered so they use their own handlers. Does it have that much overhead? Only a single loader is used for all containers. EDIT: correction, the qwikloader is used all the time, it's the single event handler that gets pinged by the DOM renderer when new event types are added. |
Beta Was this translation helpful? Give feedback.
-
|
We moved this issue to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
Since Qwik can be used to implement single views/fragments inside pages (and that can be implemented by generating containers via the
containerTagNameoption in the rendering functions) it would probably be good if qwik could clean up what it sets in the document when/if all qwik containers are no longer present on a page.As I mentioned in issue QwikDev/qwik#1482 there are definitely listeners that once added to the document seem not to be never removed.
There are also other resources that I believe could be cleaned up, for example upon interaction I noticed that styles present in the containers get moved to the head of the document, again these will stay there indefinitely even if the containers get removed.
Describe the solution you'd like
Qwik keeps track of what it applying to the document during setup (and also at other times as well) and automatically cleans up everything once/if it is no longer needed.
Describe alternatives you've considered
Qwik could provide a way for container's authors to know when a qwik container get removed from the document, they could then do some clean up, but this is probably not enough since the developers won't have knowledge of what the qwik framework has done on the page.
Encapsulating everything in the container itself and not touching any part of the document which is outside the container, making sure that when the container is removed from the page so are all the listeners and resources used by it (I am not sure, but I'd imagine that certain even listeners do need to be on the document?).
Additional context
As mentioned if developers had an already existing application and wanted to start integrating qwik parts/containers into it, the current implementation would generate memory leaks and potentially unwanted behaviours in case the qwik containers get added and removed over time.
Beta Was this translation helpful? Give feedback.
All reactions