Manage subscription between controllers

Hello,

What is the best way for you to manage a subscription which is accessed by multiple controller ?

I don’t want the subscription to be automatically closed when the controller (the scope) is destroyed. Because when the controller is load one more time, or when the user returns to this controller, the interface has to wait the subscription a new time (and this causes a flicker effect on the interface) .

Actually, to solve this problem, I manage the subscription inside a service. Inside this service, I use the natives Meteor methods to manage subscription (I dont want to have this service dependant on a angular scope…).

Thanks for your advices.

I would try using a global subscription caching object. You could do this with https://github.com/ccorcos/meteor-subs-cache (which is my preferred library) or https://github.com/kadirahq/subs-manager (the more popular choice)

If you are using ui-router, you could put the subscription on your root state controller (this is what I like to do). Otherwise, you could put it in a service and then make sure that the service is instantiated at runtime by injecting it into a run block.

This wouldn’t work so well given that the normal subscription process isn’t tied to a digest cycle, no?