mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add subscribeToCommand to track command subscriptions on other views
This commit is contained in:
@@ -39,13 +39,13 @@ class CommandPanelView extends View
|
||||
@command 'core:move-up', => @navigateBackwardInHistory()
|
||||
@command 'core:move-down', => @navigateForwardInHistory()
|
||||
|
||||
rootView.command 'command-panel:toggle', => @toggle()
|
||||
rootView.command 'command-panel:toggle-preview', => @togglePreview()
|
||||
rootView.command 'command-panel:find-in-file', => @attach('/')
|
||||
rootView.command 'command-panel:find-in-project', => @attach('Xx/')
|
||||
rootView.command 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
|
||||
rootView.command 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddress(reverse: true)
|
||||
rootView.command 'command-panel:set-selection-as-regex-address', => @setSelectionAsLastRelativeAddress()
|
||||
@subscribeToCommand rootView, 'command-panel:toggle', => @toggle()
|
||||
@subscribeToCommand rootView, 'command-panel:toggle-preview', => @togglePreview()
|
||||
@subscribeToCommand rootView, 'command-panel:find-in-file', => @attach('/')
|
||||
@subscribeToCommand rootView, 'command-panel:find-in-project', => @attach('Xx/')
|
||||
@subscribeToCommand rootView, 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
|
||||
@subscribeToCommand rootView, 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddress(reverse: true)
|
||||
@subscribeToCommand rootView, 'command-panel:set-selection-as-regex-address', => @setSelectionAsLastRelativeAddress()
|
||||
|
||||
@on 'click', '.expand', @onExpandAll
|
||||
@on 'click', '.collapse', @onCollapseAll
|
||||
|
||||
@@ -4,5 +4,10 @@ module.exports =
|
||||
@subscriptions ?= []
|
||||
@subscriptions.push(cancel: -> eventEmitter.off eventName, callback)
|
||||
|
||||
subscribeToCommand: (view, eventName, callback) ->
|
||||
view.command eventName, callback
|
||||
@subscriptions ?= []
|
||||
@subscriptions.push(cancel: -> view.off view, callback)
|
||||
|
||||
unsubscribe: ->
|
||||
subscription.cancel() for subscription in @subscriptions ? []
|
||||
|
||||
Reference in New Issue
Block a user