simple:reactive-method

v1.0.1Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Meteor Reactive Methods

Call methods synchronously inside Tracker.autorun.

Install with meteor add simple:reactive-method

Sometimes, you want to call a Meteor method inside of a template helper or Tracker.autorun computation, and get a return value. Now you can!

Before (doesn't work)

1Template.foo.helpers({
2   methodResult: function () {
3       Meteor.call("myMethod", "a", "b", function (err, result) {
4           return result; // this doesn't work!!!
5       });
6   } 
7});

After (works!)

1Template.foo.helpers({
2    methodResult: function () {
3        // Super fun!
4        return ReactiveMethod.call("myMethod", "a", "b");
5    }
6});