javascript - Move onBeforeAction hook in Meteor iron-router to different file -


i use following function helper onbeforeaction hook:

var gamefilter = function () {     this.subscribe('singlegame', this.params.slug);     var game = this.data();     if (game) {         if (game.multiplayer) {             this.redirect('multiplayerpage', {slug: this.params.slug});         } else {             this.subscribe('singleplayerpage', this.params.slug);         }     } else {         this.render(this.notfoundtemplate);     }     this.next(); }; 

i use in route:

onbeforeaction: [gamefilter, playerfilter] 

now works fantastic. however, want move filters different file. created new file in lib directory , put following code in:

gamefilter = function () {     this.subscribe('singlegame', this.params.slug);     var game = this.data();     if (game) {         if (game.multiplayer) {             this.redirect('multiplayerpage', {slug: this.params.slug});         } else {             this.subscribe('singleplayerpage', this.params.slug);         }     } else {         this.render(this.notfoundtemplate);     }     this.next(); }; 

the problem is, referenceerror, saying gamefilter not defined. think issue caused meteor's file load order. possible fix this?

i had similar issue meteor. workaround change name of file or folder number loaded first. case file called media.js , changed 1_media.js , worked


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -