Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks

Home Page:https://atmospherejs.com/matb33/collection-hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

arrow function doesnt get binded with this.previous

sirpy opened this issue · comments

commented

When using an arrow function:
(userId,doc..) => {}, this.previous is not defined
function(userId,doc...) {} works just fine

Yeah, that's how arrow functions work... Arrow functions don't have their own this and can't be given (bound) a new this value, it always uses the this in the context of where it was defined.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Here you can read up on arrow functions.