Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakschu/5858795 to your computer and use it in GitHub Desktop.
Save jakschu/5858795 to your computer and use it in GitHub Desktop.
if(Meteor.isServer){
Meteor.methods({
myMeteorMethod: function() {
// load Future
Future = Npm.require('fibers/future');
var myFuture = new Future();
// call the function and store its result
SomeAsynchronousFunction("foo", function (error,results){
if(error){
myFuture.throw(error);
}else{
myFuture.return(results);
}
});
return myFuture.wait();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment