Guest User

Untitled

a guest
Jan 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Meteor.methods({
  2. my_function: function(arg1, arg2) {
  3. //Call other asynchronous function and return result or throw error
  4. }
  5. });
  6.  
  7. Meteor.methods({
  8. my_function: function(arg1, arg2) {
  9.  
  10. // Set up a future
  11. var fut = new Future();
  12.  
  13. // This should work for any async method
  14. setTimeout(function() {
  15.  
  16. // Return the results
  17. fut.ret(message + " (delayed for 3 seconds)");
  18.  
  19. }, 3 * 1000);
  20.  
  21. // Wait for async to finish before returning
  22. // the result
  23. return fut.wait();
  24. }
  25. });
Add Comment
Please, Sign In to add comment