Arrow functions use lexical binding this, which means it thiswill be what it was when the function was created. This means that, unfortunately, you cannot use it when creating functions for objects that use object properties, such as a template.
A small example:
o = {};
o.fn = () => console.log(this);
o.fn();
o.fn = function () { console.log(this); }
o.fn();
.autorunis a template method, therefore functional binding is required this.
, , , autorun. , this , . :
Template.Hello.onRendered(() => {
this.autorun(() => {
console.log(this);
});
this.autorun(function () {
console.log(this);
}.bind(this));
this.autorun(function () {
console.log(this);
});
});