Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions react-todos/client/routes.jsx
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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();
}
Expand Down