Through the blowing snow of Meteor APIs, a 4 legged figure appeared.
It was an Imperial At-At
And the APIs it wielded were a powerful force indeed.
// Runs the function passed on the server
// conceptually: if(Meteor.isServer){ fn.call() }
Meteor.atServer(fn)
// Runs the function passed on the client
// (Meteor.isClient || Meteor.isCordova) && !Meteor.isServer
Meteor.atClient(fn)
// Meteor.isClient && !Meteor.isCordova
Meteor.atBrowser(fn)
// Meteor.isClient && Meteor.isCordova
Meteor.atCordova(fn)
// alias for Meteor.atCordova
Meteor.atDevice(fn)
Meteor.atBrowser( _.once(fn) )
- run a function in the browser only onceMeteor.atServer( _.throttle(fn, 1000) )
- run a function on the server no more than once per secondMeteor.atServer( _.defer(fn) )
- run a function once the call-stack has cleared a la setTimeout(fn, 0)- Any function on the Underscore doc site could be used, the key point being that by taking functions, your flexibility of use is improved.