So I been started using ES6 in Meteor, but apparently if you try to use Meteor.publish syntax with an arrow function, this.userId is undefined, while if you use it with a regular function(){} this.userId works perfectly, Im assuming is a kind of transpiler process that assign a different this, to userId but is just a guess, does anyone knows what really is happening?
Meteor.startup(function() {
Meteor.publish("Activities", function() { //with function
console.log(this.userId); //TS8vTE3z56LLcaCb5
});
});
Meteor.startup(function() {
Meteor.publish("Activities", ()=> { //with arrow function
console.log(this.userId); //undefined
});
});