- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2k
Closed
Description
The binding for fat arrow is lost if you wrap class method with some function. I demonstrate it with async example, but it's not tied to it, the behaviour will be the same for any other function too.
class Events
  handle: async (event) =>
    console.log @Will produce (note the this is lost, actually it's not even lost but completely wrong, the Events is used instead of this):
var Events;
Events = (function() {
  function Events() {}
  Events.prototype.handle = async(function(event) {
    return console.log(Events);
  });
  return Events;
})();It should produce:
var Events,
  bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Events = (function() {
  function Events() {
    this.handle = bind(this.handle, this);
  }
  Events.prototype.handle = async(function(event) {
    return console.log(this);
  });
  return Events;
})();Metadata
Metadata
Assignees
Labels
No labels