In my client.js i have a subscription to myCollection that triggers when there is a new Meteor.userId()
subscribe(‘myCollection’);
In my router.js i have a route like the following where i want to wait until some data are present in myCollection but i don’t want to subscribe again my collection in the waitOn because this causes to trigger another server request for publishing.
Is there a way to do that?
Router.route('/groups', {
waitOn: function(){
/*WHAT TO DO HERE? I DO NOT WANT TO SUBSCRIBE AGAIN*/
},
data: function(){
return {
/*data for templating*/
},
action: function(){
this.render();
}
});
This is a simple and effective solution, thanks!
I still have something to ask, this code does not seem to trigger the ‘loading’ template so i tried to add in the action function this code :
i’m discovering that this works only the first time but when the publish triggers again (because a new user log in, for example) is like the server does not send anymore the ready message (and i’m sure that the server calls the publish function beacuse i put a console.log there).
I’m trying to investigate by myself also, thank you very much for your help.
The server correctly sends the ready message every publish but the handler var does not update…so the route does not benefit of the ready call… we have to put the subscription inside an autorun and everything works.
this can seem a straightforward implementation here, i know, but i started with the assumption that i did not want to put the subscription in autorun that’s because i see the server publishing stuff even if my subscription is not in the autorun and i still do not fully understand this…
If you have further comments i will really appreciate them but don’t get mad with that since i have a working solution.