adobe/brackets — pull request #6154 by iwehrman (2013-12-02 17:57:38+00:00)
Title: Add event specifications to NodeConnection

The `NodeConnection` class currently parses domain specifications in order to construct wrappers around the domain's commands, and to add those wrappers to the connection object. This pull request adds domain event parsing to go along with the command parsing. It just adds the event names and their signatures to the connection, accessible by `connection.domainEvents.someDomainName`. (It would have been better to add the event specifications in the same way as the commands, but this would have required either breaking changes or polluting the existing `domains` namespace. I decided to just create a separate `domainEvents` namespace where each domain's event specifications live.)

I'm submitting this pull request because I'm also working on another wrapper around `NodeConnection` that exposes a simple interface for its most common usage: loading a single domain, executing its commands and listening for its events. The wrapper abstracts connection management and domain loading (and reloading). The goal is to eliminate a lot of existing boilerplate. It works like this:
```
var myDomain = new NodeDomain("myDomain", "/path/to/MyDomainSpec.js");

myDomain.myCommand(param1, param2)
.done(function(value) {
/* command succeeded; use the result! */
})
.fail(function (err) {
/* command failed; deal with it! */
});

$(myDomain).on("someEvent", function (param1, param2) {
/* someEvent was fired! */
});
```