title: Meteor - iron-router not waiting on subscription data in onBeforeAction hook
body: <p>I want to set a <code>Session</code> variable (<code>artistNotAvailable</code>) when the requested artist is not available. Unfortunately, the route does not work, because it is not waiting on subscription data in my <code>onBeforeAction</code> hook. <code>artistAvail</code> and <code>artist</code> is undefined, but not because there is no artist in the DB, I think it is a subscription problem. I debugged it and calling <code>Artists.find().fetch();</code> in the browsers console returned <code>undefined</code>.</p>
  
  <p>Here is my route:</p>
  
  <pre><code>this.route('eventPage', {
          path: '/event/:slug/:openDate?/:closeDate?',
          onBeforeAction: [teamFilter, function() {
              var event = this.data();
              if (event.outdoor) {
                  this.subscribe('artists', this.params.slug);
                  if (this.ready()) {
                      var artistAvail = Artists.findOne({eventId: event._id, openDate: moment(this.params.openDate).toDate(), closeDate: moment(this.params.closeDate).toDate()});
                      if ((!this.params.openDate &amp;&amp; !this.params.closeDate) || typeof artistAvail === "undefined") {
                          var artist = Artists.findOne({
                              eventId: event._id,
                              openDate: {$lte: new Date()},
                              closeDate: {$gte: new Date()}
                          });
                          if (Artists.find().count() &gt; 0 &amp;&amp; artist) {
                              Session.set('artistNotAvailable', true);
                              this.redirect('eventPage', {
                                  slug: this.params.slug,
                                  openDate: moment(artist.openDate).format('YYYY-MM-DD'),
                                  closeDate: moment(artist.closeDate).format('YYYY-MM-DD')
                              });
                          } else {
                              Session.set('noArtists', true);
                              this.redirect('overviewPage', {slug: this.params.slug});
                          }
                      } else {
                          this.subscribe('musicOutdoor', this.params.slug, moment(this.params.openDate).toDate(), moment(this.params.closeDate).toDate());
                          if (this.ready()) {
                              var guestsIds = new Array();
                              Guests.find({artistId: artistAvail._id}).forEach(function (guest) {
                                  guestIds.push(guest._id);
                              });
                              this.subscribe('guestsOutdoor', guestIds);
                          } else {
                              this.render('loading');
                          }
                      }
                  } else {
                      this.render('loading');
                  }
              } else {
                  this.subscribe('musicIndoor', this.params.slug);
                  this.subscribe('guestsIndoor', this.params.slug);
                  if (!this.ready()) {
                      this.render('loading');
                  }
                  this.next();
              }
              this.next();
          }],
          waitOn: function() { return [Meteor.subscribe('singleEvent', this.params.slug)]; },
          data: function() {
              return Events.findOne({slug: this.params.slug});
          }
      });
  </code></pre>
  
  <p>Subscription:</p>
  
  <pre><code>Meteor.publish('artists', function(slug) {
      var event = Events.findOne({slug: slug});
      if (event) {
          return Artists.find({eventId: event._id});
      } else {
          return null;
      }
  }); 
  </code></pre>
  
  <p>Now the problem is that when I access the <code>eventPage</code> with a wrong <code>openDate</code> or <code>closeDate</code> I will be redirected to the <code>overviewPage</code>, even though there are artists in the db. As already mentioned, I debugged it and it seems to be that <code>this.ready()</code> is not working.
  I really miss <code>.wait()</code> :-(</p>
  
  <p>Any help would be greatly appreciated.</p>