meteor-collection-helpers
meteor-collection-helpers copied to clipboard
Ecmascript problem
I used a global helper below. However after I changed to ES6 or 2015 format, it broke.
Original
Channels.helpers({
oppParty: function (){
if( this.originator === Meteor.userId() ) {
return Meteor.users.findOne({ _id: this.recipient });
} else {
return Meteor.users.findOne({ _id: this.originator });
}
}
});
changed to
Channels.helpers({
oppParty (){ return this.originator === Meteor.userId() ? this.recipient : this.originator; }
});
I tried various combination and installed, uninstalled ES6, nothing worked. Anyone has the same issue?
Using object method shorthand is okay however don't use arrow functions as then this won't be bound to the correct context. Could you post a more complete code example?
@dburles updated as above. Thanks!
Looks fine to me (see the examples in the readme).