Skip to content
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

Question: how to handle reconnect properly? #5

Open
zhaoyao91 opened this issue Apr 6, 2021 · 1 comment
Open

Question: how to handle reconnect properly? #5

zhaoyao91 opened this issue Apr 6, 2021 · 1 comment

Comments

@zhaoyao91
Copy link

Standard web component has 3 key lifecycle point: create(constructor), connected, disconnected. This is because an element may be remove from dom and added back again and again. With these hooks, we could create something in constructure but reuse them from time to time.

But lifecycles defined by this repo are only create and release, which means we have to recreate all thing after reconnecting.

Am I missing something? Or how could we handle this?

@ryansolid
Copy link
Owner

Yeah. I built this so that while it can handle moves that when the element has been disconnected I free up reactivity (basically dispose) and when connected I create again. I'm not sure if there is a way around this because otherwise we'd have potential memory leaks and there is no onDispose hook in the native DOM only disconnect. I have no way to automatically cleanup after ourselves.

Not sure if there is some clever trick I'm missing but this is just one of those things that I've considered from the beginning since I was dealing with reactive libraries which innately have leaky observer potential. Using something like a WeakMap is non-starter since besides not being able to change other libraries internals they can't be iterated on as subscriptions. We need a definite even to tie into to free up long live subscriptions. At which point we need to re-evaluate all those computations again which I basically can't do without recreation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants