So, I started using ES6 in Meteor , but apparently if you try to use the Meteor.publish syntax with an arrow, this.userId is undefined, and if you use it with a regular function(){} this.userId works fine, I assume that this is a kind of transpiler process that assigns a different value to userId , but this is just an assumption, does anyone know what is actually 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 }); });
javascript ecmascript-6 meteor meteor-publications
ncubica
source share