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

Store signals after SPA navigation are losed #208

Closed
aralroca opened this issue May 26, 2024 · 1 comment · Fixed by #210
Closed

Store signals after SPA navigation are losed #208

aralroca opened this issue May 26, 2024 · 1 comment · Fixed by #210
Assignees
Labels
bug Something isn't working

Comments

@aralroca
Copy link
Collaborator

Probably related to #207 but different

After each SPA navigation, the store is initialized again, losing the registered signals on existing components. During SPA is not unmounting the web components that didn't change, so if they already have registered store signals, then updating the store is not reactive to the web components anymore.

@aralroca aralroca self-assigned this May 26, 2024
@aralroca aralroca added the bug Something isn't working label May 26, 2024
@aralroca
Copy link
Collaborator Author

The problem is that the subscription is re-created again and registering again the listeners:

const subscription = createSubscription();

Something like this can solve the problem:

window.subscription ??= createSubscription();

The logic inside signals of each web component is in charge of cleaning the listeners of the store it had, so when browsing it is cleaned and the listeners of the components that have not changed are preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant