Created
May 26, 2015 23:56
-
-
Save bobrocke/84e5609afd8f0bc08fcb to your computer and use it in GitHub Desktop.
Atom Command Registration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
activate: function(state) { | |
this.subscriptions = new CompositeDisposable(); | |
this.subscriptions.add(atom.commands.add('.platform-darwin .tree-view', { | |
'open-a-terminal:openroot': (function(_this) { | |
return function() { | |
return _this.openroot(); | |
}; | |
})(this) | |
})); | |
this.subscriptions.add(atom.commands.add('.platform-darwin .tree-view', { | |
'open-a-terminal:openhere': (function(_this) { | |
return function() { | |
return _this.openhere(); | |
}; | |
})(this) | |
})); | |
}, |
This is what worked:
activate: function(state) {
var self = this;
this.subscriptions = new CompositeDisposable();
this.subscriptions.add(
atom.commands.add(
'.tree-view',
{
'open-a-terminal:openroot': function() { return self.openroot();},
'open-a-terminal:openhere': function() { return self.openhere();}
}
)
);
},
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From Michael Bolin:
() => this.openroot()` is sufficient in ES6 when the body of the function is a single expression