fix(prefs): atom.keymaps does not implement unsubscribe

https://github.com/atom/atom-keymap/issues/101
This commit is contained in:
Ben Gotow 2015-11-09 21:44:59 -08:00
parent 0650768788
commit 08db4679aa

View file

@ -25,11 +25,14 @@ class PreferencesKeymaps extends React.Component
@_loadTemplates() @_loadTemplates()
componentDidMount: => componentDidMount: =>
@unsubscribe = atom.keymaps.onDidReloadKeymap => @_mounted = true
atom.keymaps.onDidReloadKeymap =>
# Temporary fix for https://github.com/atom/atom-keymap/issues/101
return unless @_mounted
@setState(bindings: @_getStateFromKeymaps()) @setState(bindings: @_getStateFromKeymaps())
componentWillUnmount: => componentWillUnmount: =>
@unsubscribe?() @_mounted = false
_loadTemplates: => _loadTemplates: =>
templatesDir = path.join(atom.getLoadSettings().resourcePath, 'keymaps', 'templates') templatesDir = path.join(atom.getLoadSettings().resourcePath, 'keymaps', 'templates')