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
onStop callback for Meteor.subscribe #1461
Comments
For example, calling |
My initial reaction was "why don't you just call your callback when you call Design questions include: should it be called in addition to |
In fact, my idea was to get a callback on the client, when the server stops the subscription. For
So no, it should be useful especially for server initiated stops. So if subscription is stopped by the server before
Why would it be useful to run outside Deps context? I would do what is the most expected. Because you are passing callback inside the |
onError does run for server side stops, I thought. |
Not when I tested it? |
I tried:
And I get only |
In any case, calling |
Oh, sorry, you're completely right about onError. On Wed, Oct 9, 2013 at 7:19 PM, Mitar notifications@github.com wrote:
|
I think it is a different semantic purpose. I feel like passing a valid return value should not be mixed with error return value. Maybe you want for errors some global handling, but for values local handling. |
I'm currently working with observeChanges on the client and filling out a search results table with results of what was typed in a search box. the search actually changes the arguments to the subscription. It seems when that happens, Meteor ends the current subscription and starts a new one. The observeChanges first gets added callbacks for each item from the new subscription, then it gets all the removed callbacks from the last subscription. Sometimes a few seconds later depending on how large the result of the new subscription is. I think this behavior is fine, but it would be nice to have some loading indicator so the user isn't confused by seeing results from the last search for several seconds while the new subscription is populating and the old subscription is clearing out. it would be nice to provide some kind of method to find out when the old subscription is actually stopped, i.e. all it's items have been cleared out of the local collection. Because the subscriptions are the same one from the point of view of my code, only the arguments have changes, I have no way now to do this transition. I've looked through the actual server messages that are coming across the wire and it seems there is a nosub message from the previous subscription which always fires once all the remove messages have come across the wire, but I see no way to tie into this in the Meteor code handling the connection. From what I can see it's only used for error handling and if the unsubscribe was stopped by the current client process, the message is just dropped. Any thoughts on some way to tie into this in the client code so we can do smoother transitions from one subscription to the next? |
Forgot to include a link to the post I made on meteor-talk giving more detail on what was observed from the current behavior: https://groups.google.com/forum/#!topic/meteor-talk/KvcvUY9oBgg |
Yes, there are two things missing.
and then wait before the next block of tests that subscription is really stopped and all documents removed. |
In other words, how to get a callback when |
Also, add subscriptionId to handles Fixes #1461
Amazing! |
Hehe such a fast response time. |
@bline: |
@mitar, did you find a way to achieve that? |
In next release of Meteor, there will be this |
Testing this but I can get this working. Created issue here: Urigo/angular-meteor#1584 |
Would it be possible to provide
onStop
callback for Meteor.subscribe? So that some additional cleanup can be done afterwards? In this way it is easier to have logic chained together: you first subscribe and do other initialization stuff, and when you move to another page, you just kill subscription and the rest will follow? I agree that many things can be done without it, but it seems to me that it opens sometimes a path to do some things easier.The text was updated successfully, but these errors were encountered: