Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
658 stars 90 forks source link

arrow function doesnt get binded with this.previous #242

Closed sirpy closed 6 years ago

sirpy commented 6 years ago

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

zimme commented 6 years ago

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.