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
Post a Comment