2014-11-01 13 views
8

ho aggiornato a Meteor 1.0, installato l'ultimo pacchetto di ferro-router, hanno cercato di correre la mia app e ottenuto questo bel avvertimento nel mio log della console:totalmente confuso circa this.next() in Meteor ferro-router

Spedizione rotta mai visualizzata. Hai dimenticato di chiamare this.next() in un onBeforeAction?

Così ho provato a modificare i miei percorsi in base alla nuova versione.

this.route('gamePage', { 
     path: '/game/:slug/', 
     onBeforeAction: [function() { 
      this.subscribe('singlePlayer', this.params.slug).wait(); 
      var singlePlayer = this.data(); 
      if (singlePlayer) { 
       if (singlePlayer.upgrade) { 
        this.subscribe('upgrades', this.params.slug).wait(); 
        this.next(); 
       } 
       this.next(); 
      } 
      this.next(); 
     }], 
     data: function() { 
      return Games.findOne({slug: this.params.slug}); 
     }, 
     waitOn: function() { return [Meteor.subscribe('singleGame', this.params.slug)]} 
    }); 

Come posso risolvere questo? Qualsiasi aiuto sarebbe molto apprezzato.

risposta

9

Provare a rimuovere tutti gli .wait() e rimuovere l'array attorno alla funzione onBefore.

Con la nuova API this.next() sostituisce .wait().

+0

Grazie! Che funzioni! Ho bisogno di 3 x 'this.next()' o solo una volta alla fine della funzione? – user3475602

+0

Potrebbe non essere necessario per il primo 'if'. Fare un tentativo e riferire. – benstr

+0

Questo ha funzionato per me: 'if (singlePlayer) { if (singlePlayer.upgrade) { this.subscribe ('upgrades', this.params.slug) .wait(); } } this.next(); ' Potresti spiegare dove dovrei posizionare' this.next() 'in generale? Il metodo Trial-and-error è un po 'frustrante. – user3475602

Problemi correlati