mirror of
https://github.com/atom/atom.git
synced 2026-02-17 18:11:29 -05:00
Allow multiple commands to be registered by passing an object
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{Disposable} = require 'event-kit'
|
||||
{Disposable, CompositeDisposable} = require 'event-kit'
|
||||
{specificity} = require 'clear-cut'
|
||||
|
||||
SequenceCount = 0
|
||||
@@ -10,6 +10,13 @@ class CommandRegistry
|
||||
@listenersByCommandName = {}
|
||||
|
||||
add: (selector, commandName, callback) ->
|
||||
if typeof commandName is 'object'
|
||||
commands = commandName
|
||||
disposable = new CompositeDisposable
|
||||
for commandName, callback of commands
|
||||
disposable.add @add(selector, commandName, callback)
|
||||
return disposable
|
||||
|
||||
unless @listenersByCommandName[commandName]?
|
||||
@rootNode.addEventListener(commandName, @dispatchCommand, true)
|
||||
@listenersByCommandName[commandName] = []
|
||||
|
||||
Reference in New Issue
Block a user