Template.subscribe and subsmanager


Is there a way to use the new Template.subscribe with the subsmanager package?

I know you can do it using the older pattern of doing template level subscriptions, but not sure how you’d do it using template.subscribe.


Subscription management FAQ

Wondering this myself too!


You can just wrap you subscription call in a Template.autorun.


Yeah. This is the old way to do it.


Sure. But if template.subscribe uses Meteor.subscribe. If you want to use a subs manager then you’ll have to wrap it in an autorun to get template-level subscriptions


I think I might be still too stupid to understand. Taking the example below. I think what you are saying is: If you wrap the subs-Cache call in a template.autorun similar to as shown, then the subscribe will automatically do its subscribe/unsubscribe magic when the template is created and destoryed.

I think there is a second part of the question that isn’t clear to me and maybe the OP. How do you use subs-Cache in-place of this.subscribe such that the ids the subscriptions made by a subs-Cache subscribe make it into _subscriptionHandles and _allSubsReady part of this.subscribe? Or otherwise asked how do you get {{#if Template.subscriptionsReady}} and functionTemplate.instance().subscriptionsReady() to depend on Template subscriptions made with subs-Cache.

# in some top level file
share.subsCache = new SubsCache( 
  expireAter: 5  
  cacheLimit: 10

#in a template file
Template.entryRevisionInfo.onCreated ->
  self = @
  self.autorun ->


Correct. It doesn’t seem like there’s a way to do it at the moment. So you
have to use autorun and you’re own reactive subsready variable to create
the same functionality.