Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor.autorun vs Tracker.autorun?

What is the difference between Meteor.autorun and Tracker.autorun?

  • are they just aliases?
  • is one deprecated?
  • is there any instance where one is preferable to the other?

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.

like image 854
bigmadwolf Avatar asked Oct 24 '15 15:10

bigmadwolf


1 Answers

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...

like image 186
Kyll Avatar answered Oct 25 '22 22:10

Kyll