javascript - 创建全局铁:router subscription?的正确方法是什么

标签 javascript meteor iron-router

我需要为应用程序中的每条路线进行特定订阅,这可行,但我不确定它是否正确?

Router.onBeforeAction(function() {
    Meteor.subscribe('locations');
    this.next();
});

另外,有没有办法全局 waitOn() ?

最佳答案

您可以使用 Router.configure({}); 声明可在全局级别的路由上设置的任何选项。要使用上面的示例:

Router.configure({
    waitOn: function() {
        return Meteor.subscribe('locations');
    }
});

上面将通过在全局路由上下文中使用 waitOn 选项为您的应用程序中的所有路由提供指定的订阅。有关可以在全局级别上为路由设置的所有其他选项的更多信息,请查看 this出来。

关于javascript - 创建全局铁:router subscription?的正确方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29058823/

相关文章:

javascript - 使用 lodash 查找转置矩阵

javascript - 删除数组数组的第一项

meteor - 如何避免cursor.observe 上的竞争条件?

javascript - 单 View 页面永久链接为空,带有 Iron Router

Javascript For..In 循环执行 if 和 else 语句

javascript - 如何创建一个字典,使用单词的频率作为键?

javascript - Meteor-Random - 如何知道生成器是强还是弱

javascript - Meteor 账户路由

meteor - 在 Flow Router 中等待订阅

javascript - Meteor 中 3 个订阅的响应式(Reactive)加入