Provides future
implementation for Meteor.call
functions returning data to the client side.
Last active
September 22, 2017 19:09
-
-
Save aaronthorp/8324787 to your computer and use it in GitHub Desktop.
Meteor.js - Fibers/Future For Client-Server Return. @aaronthorp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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