Skip to content

Instantly share code, notes, and snippets.

@aaronthorp
Last active September 22, 2017 19:09
Show Gist options
  • Save aaronthorp/8324787 to your computer and use it in GitHub Desktop.
Save aaronthorp/8324787 to your computer and use it in GitHub Desktop.
Meteor.js - Fibers/Future For Client-Server Return. @aaronthorp

Meteor.js - Fibers/Future For Client-Server Return

Provides future implementation for Meteor.call functions returning data to the client side.

Support us via Gittip

if (Meteor.isClient) {
Template.foo.rendered = function() {
Meteor.call('do_something', 'valid_data', function(err, result) {
Session('barData') = result;
});
};
Template.foo.helpers({
bar: function() {
return Session('barData');
}
});
}
if (Meteor.isServer) {
Future = Npm.require('fibers/future');
Meteor.methods({
do_something: function (data) {
var fut = new Future();
if (data.check_me === 'valid_data')
fut.return(true);
else
fut.return(false);
return fut.wait();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment