【发布时间】:2015-06-24 22:25:09
【问题描述】:
Meteor 最近引入了模板订阅功能。您现在可以在 Temeplate.xyz.onCreated 调用中调用 this.subscribe,并且只有在服务器准备好订阅后,帮助程序 {{#if Template.subscriptionsReady}} 才会为真。
不幸的是,这似乎与subs-manager 或subs-Cache 不兼容
您将如何使用 subs-Cache 代替 this.subscribe 以便订阅管理器生成的订阅 ID 使其成为 this.subscribe 的 _subscriptionHandles 和 _allSubsReady 部分?或者另外问,你如何让 {{#if Template.subscriptionsReady}} 和函数 Template.instance().subscriptionsReady() 依赖于使用 subs-Cache 进行的模板订阅。
不起作用的示例代码:
# in some top level file
share.subsCache = new SubsCache(
expireAter: 5
cacheLimit: 10
)
#in a template file
Template.entryRevisionInfo.onCreated ->
share.subsCache.subscribe('somePub')
【问题讨论】:
-
您找到解决方案了吗?
-
不抱歉,我没有,不过我会加个赏金看看是否有什么好处
标签: templates meteor publish-subscribe