Skip to content

Commit

Permalink
don't wait on subscriptions, fixes #80
Browse files Browse the repository at this point in the history
As a side effect, this will not show a loading indicator.
  • Loading branch information
Rayman committed Sep 21, 2014
1 parent cc667f0 commit f7bec01
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions both/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Router.configure({
}
});

// enable hooks
if (Meteor.isClient) {
Router.onBeforeAction('dataNotFound');
Router.onBeforeAction('loading');
}

// global configuration
Router.waitOn(function() {
return [Meteor.subscribe('allplaylists'),
Expand Down Expand Up @@ -37,19 +43,20 @@ Router.map(function() {

this.route('playlist', {
path: '/playlist/:_id',
waitOn: function() {
return Meteor.subscribe('playlist',this.params._id);
},
onBeforeAction: function() {
console.log("subscribe to playlist", this.params._id);
this.subscribe('playlist', this.params._id);
var playlist = this.data();
if (!playlist)
if (!playlist) {
console.warn("no playlist");
return;
}
var songs = playlist.songs || [];
songs = _.pluck(songs, 'songId');
//add another subscription to waiting list
this.subscribe('songs', songs);
},
//loadingTemplate: 'playlist',
loadingTemplate: 'playlist',
notFoundTemplate: 'playlistNotFound',
data: function() {
//return all current client side playlists (just one ;)
Expand Down

0 comments on commit f7bec01

Please sign in to comment.