From 8e66b1a76751213cd5247a3b3263f96493807a68 Mon Sep 17 00:00:00 2001 From: febbweiss Date: Thu, 5 Nov 2015 09:26:12 +0000 Subject: [PATCH] Optim: subscriptions managed by router --- client/loading.html | 3 +++ client/projects.js | 4 ---- lib/routes.js | 10 +++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 client/loading.html diff --git a/client/loading.html b/client/loading.html new file mode 100644 index 0000000..40796df --- /dev/null +++ b/client/loading.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/client/projects.js b/client/projects.js index 4fbfd58..fc87a0c 100644 --- a/client/projects.js +++ b/client/projects.js @@ -1,7 +1,3 @@ -Template.management.onCreated(function(){ - Meteor.subscribe('projects'); -}); - Template.management.helpers({ projects: function () { return ProjectService.list(); diff --git a/lib/routes.js b/lib/routes.js index 6c1463f..4c42b21 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -7,5 +7,13 @@ Router.map(function () { this.route('home', { path: '/', }); - this.route('management'); + this.route('management', function() { + this.subscribe('projects').wait(); + + if (this.ready()) { + this.render(); + } else { + this.render('Loading'); + } + }); }); \ No newline at end of file