Reputation: 3519
What is the difference between Meteor.autorun
and Tracker.autorun
?
I'm well aware of the difference in using this.autorun
in template lifecycle callbacks, but have seen these two used interchangeably and just want to be sure I haven't missed a trick.
Upvotes: 9
Views: 2479
Reputation: 659
Try to run Meteor.autorun();
in the console, it throws the following error Uncaught Error: Tracker.autorun requires a function argument
like you were trying to run Tracker.autorun();
Upvotes: 0
Reputation: 7139
Well, it can easily be found out with the identity operator.
This will be false
because it is not the same function:
(function() {} === function() {})
Let's try with the two autorun
:
(Meteor.autorun === Tracker.autorun)
This returns true
. So yes it's only a pure alias.
However, only Tracker.autorun
is documented. I suspect some kind of old API left for compatibility...
Let's check some Meteor code on GitHub!
File :
deprecated.js
Meteor.autorun = Tracker.autorun;
This is in deprecated.js
, it says some things about //Deprecated functions
and some backward compatibility with Meteor 0.5.4. It seems pretty clear which one you should use.
You can find some other old timers in there, such as Deps
...
Upvotes: 16