g'day, I read meteor was going all ecmascript 6 - and thought awesome... "I never have to write 'function' again" - so quickly changed a bunch of functions over to lambdas... only to discover it doesn't work :(
If you write a helper function in meteor - you get the data context passed in in the "this" property - but of course, lambdas use a lexical this - so I understand the problem pretty simply.
the thing is - what is not obvious to me is the solution - any idea how you would make a helper function using the () => notation that needs the current data context? It doesn't seem to live anywhere other than "this"?
ECMAScript 2015 didn't deprecate
function()
. Arrow functions are not shorthand syntax, they have different semantics, most notably, lexicalthis
binding.You can't have a contextual
this
in an arrow function - use standard functions instead.Use shorthand for defining functions as object properties:
But if you really want to use
() =>
syntax, you may be interested in usingTemplate.currentData()
instead ofthis
:From documentation: