This method is a wrapper of Tracker.autorun and shares exactly the same API.
The autorun method is part of the ReactiveContext, and available on every context and $scope.
The argument of this method is a callback, which will be called each time Autorun will be used.
The Autorun will stop automatically when when it's context ($scope) is destroyed.
| Name | Type | Details | Required |
|---|---|---|---|
| runFunc | Function | The function to run. It receives one argument: the Computation object that will be returned. | Yes |
getReactively:myModule.controller('MyCtrl', ['$scope', '$reactive', function($scope, $reactive) {
$reactive(this).attach($scope);
this.myVar = 10;
this.autorun(() => {
console.log('Autorun!!', this.getReactively('myVar'));
});
this.myVar = 50; // This will cause the autorun function method to run again
}]);