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

How are subscriptions stopped? #14

Closed
Prinzhorn opened this issue Sep 29, 2021 · 2 comments
Closed

How are subscriptions stopped? #14

Prinzhorn opened this issue Sep 29, 2021 · 2 comments

Comments

@Prinzhorn
Copy link

Prinzhorn commented Sep 29, 2021

I'm probably just very confused right now. To track down some subscription issue I've narrowed it down to this:

<script>
  import { Meteor } from 'meteor/meteor';
  Meteor.subscribe('contacts');
</script>

If I render this component conditionally (toggling a checkbox) it will subscribe / unsubscribe from contacts. How? There is no $m or Tracker. I also can't see an onDestroy being generated for this component. What is this magic and how do I disable it? Does melte somehow globally wrap every component in a Tracker?

Edit: I need this because I want certain subscriptions to be subscribed to lazily (once needed) but then keep them open forever. I had this abstracted away and wondered why it was unsubscribing.

@zodern
Copy link
Owner

zodern commented Sep 29, 2021

Is rdb:svelte-meteor-data in .meteor/versions? It modifies Meteor.subscribe to automatically unsubscribe when the component is destroyed.

@Prinzhorn
Copy link
Author

Thank you very much, it is indeed! I was using the official Svelte skeleton and it includes both packages (https://github.com/meteor/meteor/blob/de41620db3ebd68e223fb1ae0a0eba9fd91cc700/tools/static-assets/skel-svelte/.meteor/packages).

I see value in both packages, but I like how unobtrusive this package is. I'll stick with it, thanks for creating it.

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