WIP: pushing message id to front of message data so browser process can reply

This commit is contained in:
Nathan Sobo
2012-08-28 17:20:49 -05:00
parent 7bfc97c4c4
commit 74bf4db5fc
2 changed files with 22 additions and 1 deletions

View File

@@ -1,2 +1,20 @@
messageIdCounter = 1
originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess
atom.pendingBrowserProcessCallbacks = {}
atom.sendMessageToBrowserProcess = (name, data, callback) ->
messageId = messageIdCounter++
data.unshift(messageId)
pendingBrowserProcessCallbacks[messageId] = callback
atom.open = (args...) ->
@sendMessageToBrowserProcess('open', args)
atom.confirm = (prompt, buttonsAndCallbacks...) ->
console.log prompt, buttonsAndCallbacks
atom.confirm "Are you sure?",
"Yes", (-> )
"No", (-> )