busykai/brackets-livedev2 — pull request #13 by sebaslv (2014-06-23 13:02:38+00:00)
Title: Better message handling at protocol layer

Make some changes to messaging infrastructure:
- Decouple implementation of remote commands from ProtocolHandler. Transport now receives a message handler that just propagates messages to a MessageBroker. Handlers subscribe to particular messages for providing command implementation.
- Add events for remote page life-cycle 'Page.loadEventFired' and 'Page.unloadEventFired' which allows better control from Editor's side.
- Fixes life cycle problems for lightweight documents in related docs sequence. (listeners were not registered at the right time since they were injected with RemoteProtocol which is executed after page is loaded in some cases)
- Add some draft concept of domain (CDT-like), just to provide a better way of organizing remote commands.
- Protocol now triggers custom events based on method name which allows re-factor into different handlers per event rather than parsing messages content on a unique message handler.

It makes remote commands implementation more flexible (eg. events can be composed to create pipes of message processing). Initial implementation which provides static domain and command registration but it can be a step forward on making them dynamic and more extensible for a long term solution.