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

Fix Notification components possible memory leaks #650

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

jbaez
Copy link
Contributor

@jbaez jbaez commented Sep 9, 2022

Dispose subscriptions and timeouts when the components are removed from the DOM.

Currently it probably doesn't create memory leaks since the NotificationList is shown in the base layout as a singleton component. But if at some point we add a feature to dismiss a notification on click, then it might create a memory leak.

Added affected components tests to validate changes.

Dispose subscriptions and timeouts when
the components are removed from the DOM
notificationController.notificationList.subscribe((list) => {
notificationList = list;
});
const { notificationList } = notificationController;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this so much since I discovered I could just destruct a variable to use the Writable property directly without subscribing 😝. Thanks Jaime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes very handy, and Svelte takes care of unsubscribing automatically 😄

@alextran1502 alextran1502 merged commit b6d025d into main Sep 9, 2022
@alextran1502 alextran1502 deleted the fix/notification-subscriptions branch September 9, 2022 12:40
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

Successfully merging this pull request may close these issues.

None yet

2 participants