meteor - 如何在 Iron Router blaze 集成上正确地用 pause() 替换 this.stop()

标签 meteor iron-router

当我将 Iron Router 升级到 blaze 集成分支时,我开始收到此警告:

"You called this.stop() inside a hook or your action function but you should use pause() now instead" 

Chrome 控制台 --> iron-router.js:2104 --> 包中的 client/route_controller.js:193

代码在客户端:
Router.before(mustBeSignedIn, {except: ['userSignin', 'userSignup', 'home']});

var mustBeSignedIn = function () {
    if (!Meteor.user()) {
        // render the home template 
        this.redirect('home');
        // stop the rest of the before hooks and the action function 
        this.stop();
        return false;
    }
    return true;
}

我尝试更换 this.stop()与:pause() , Router.pause()this.pause()但仍然不起作用。另外我还没有在铁路由器包上找到暂停功能。

如何正确更换 this.stop()pause() ?

谢谢

最佳答案

我开了一个 issue在 Github 上关于这个。这是我得到的回应:

Oops I may have not changed the redirect method yet. Just use Router.go as it will work fine now. I will change over this.redirect sometime next week or a PR is welcome. Controllers are now automatically stopped if you change routes in a hook. You can pause the current run by calling the pause method which is passed as a parameter to your hooks and action functions.

关于meteor - 如何在 Iron Router blaze 集成上正确地用 pause() 替换 this.stop(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22114572/

相关文章:

javascript - meteor 排行榜应用程序

javascript - Meteor 中登录尝试的 DDP 速率限制器

meteor - meteor 的 Nginx 配置

javascript - 我如何在单个 react 表中使用两个集合?

javascript - 全局模板助手在meteor部署服务器上未定义

javascript - 第一次单击浏览器后退时无法让 Iron 路由器工作

javascript - Meteor 重启时 Meteor.users 尚未准备好

Meteor.Router vs Iron Router

javascript - meteor +MongoDB : How to get nested data?

javascript - 错误 : Did not check() all arguments during publisher