How do you use global Coffeescript variables on client startup in Meteor? -
in lib.coffee have @x = 1. in client.coffee have meteor.subscribe('data', x). when page loads, error in console:
uncaught referenceerror: x not defined
however, after page has finished loading, , type x in console, recognized global variable value 1.
it has order in source files evaluated. details, have careful read of this section of docs. can play number of games file names , locations in order change load order:
- change file names appear in alphabetical order
- put files need loaded first in subdirectory
- put files need loaded first in
libdirectory
in particular case, however, can delay activation of subscription, doing like:
meteor.startup -> meteor.subscribe 'data', x or
tracker.autorun -> if meteor.userid() meteor.subscribe 'data', x tricks these can used execute code after of source files has been evaluated.
Comments
Post a Comment