Totally confused about this.next() in Meteor iron-router

孤人 提交于 2019-12-23 07:49:01

问题


I upgraded to Meteor 1.0, installed the latest iron-router package, tried to run my app and got this nice warning in my console log:

Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?

So I tried to modify my routes according to the new version.

this.route('gamePage', {
        path: '/game/:slug/',
        onBeforeAction: [function() {
            this.subscribe('singlePlayer', this.params.slug).wait();
            var singlePlayer = this.data();
            if (singlePlayer) {
                if (singlePlayer.upgrade) {
                    this.subscribe('upgrades', this.params.slug).wait();
                    this.next();
                }
                this.next();
            }
            this.next();
        }],
        data: function() {
            return Games.findOne({slug: this.params.slug});
        },
        waitOn: function() { return [Meteor.subscribe('singleGame', this.params.slug)]}
    });

How can I fix this? Any help would be greatly appreciated.


回答1:


Try removing all the .wait()s and removing the array around your onBefore function.

With the new API this.next() replaces .wait().



来源:https://stackoverflow.com/questions/26692789/totally-confused-about-this-next-in-meteor-iron-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!