How to know when a subscription has finished stopping?


#1

Meteor.subscribe() returns a subscription object with a stop() method. The stop() method cancels the subscription and remove the subscription’s data from the client’s cache.
How can I be informed when the cache has been updated?

Same question with subscribe in autorun: how can I be informed when the cache has been updated after a subscription has been stopped and re-run? (this relates to this Meteor issue).


Overlap when subscriptions with skip/limit and subscriptionsReady
#2

You can pass a function as argument to the subscribe method. That function is called when the subscription is ready.

http://docs.meteor.com/#/full/meteor_subscribe


#3

There are 2 callbacks you can pass to the subscribe function:

  • onError: called whenever an error occurs.
  • onReady: called once all new documents have been added to the local cache (notice that documents might still be removed after onReady has been called, see https://github.com/meteor/meteor/issues/3194).

None of those callbacks are called whenever a stopped subscription has finished clearing the local cache, are they?


#4

I think @sashko was working on such feature recently.


#5

#6

Thanks @slava.

But two different requirements are discussed in this thread. As mitar said:

There are two things missing. onStop argument which you would pass at subscription time. But also a callback to .stop() [allowing to wait] that subscription is really stopped and all documents removed.

It seems @sashko’s commit is for the first requirement only, not the second one.


Good drop-in comment system for docs.meteor.com
#7

@sashko, it would be great if you could summarize your work on this.

Is the onStop mentioned here the same as the onStopped mentioned in the title of this commit?

If one of those new features allows to know when the local cache has been updated after calling stop, did you think about a way to know the same in the case of a subscription automatically stopped and re-run inside an autorun?

Thanks,


#8

@sashko, any insight?