diff --git a/react-todos/client/routes.jsx b/react-todos/client/routes.jsx index 87d76ce7..c81aa060 100644 --- a/react-todos/client/routes.jsx +++ b/react-todos/client/routes.jsx @@ -1,10 +1,9 @@ // This data is used on every page; also we want to make sure we route to the // first list instead of no list at all -var handles = [ - Meteor.subscribe("publicLists"), - Meteor.subscribe("privateLists") -]; -var subsReady; +FlowRouter.subscriptions = function () { + this.register('publicLists', Meteor.subscribe('publicLists')); + this.register('privateLists', Meteor.subscribe('privateLists')); +}; FlowRouter.route("/", { name: "root", @@ -28,13 +27,8 @@ FlowRouter.route("/lists/:listId", { // XXX this should be replaced by promises, probably... Tracker.autorun(function (computation) { - // Are all of the subscriptions done yet? - subsReady = _.all(handles, function (handle) { - return handle.ready(); - }); - - // If they are, and we are at the root route, we should go to a valid list - if (subsReady && FlowRouter.current().name === "root") { + // If the data's ready, and we are at the root route, we should go to a valid list + if (FlowRouter.subsReady() && FlowRouter.getRouteName() === "root") { FlowRouter.go("todoList", { listId: Lists.findOne()._id }); computation.stop(); }