| > if your topics and channels are well-defined and documented in one place That's the problem. It's hard to get this done. Developers like to develop, it's like pulling teeth to get us to document things. I've found its much easier and faster to have a codebase that speaks-for-itself, in a way. Don't get me wrong, we definitely do document things. But the miniscule things like implementation details are just too small to be worth spending time on. We've been in production for about 7 years now. Our team has pretty much completely turned over in that time. Knowledge and conventions get lost, much better to have the codebase dictate how things should be done. A developer will read the code+comments before they read the documentation. Hmm how to explain live-binding... Angular's $scope and CanJS' Observables are examples of live-binding. Basically, you can pass around a live-binding object and changes made to it in one module are immediately reflected in another. Whereas with a pub/sub model, you publish messages out to a hub and it is up to the module to decide how to react to the message. A good example of how we use live-binding is with sessions. We have a global live-bound object that holds the session data. Each module that needs to use session info simply refers to this global object. If we perform an API call that returns 401 and kills the session, our API module kills the session object and all our modules immediately respond to this change. We don't have to declare any listeners, or subscribe to any pubs; we just use the object. |
This can work pretty good up to certain level but after that this can go out of hand pretty quickly. The cascading effect will become hard to debug.
> Whereas with a pub/sub model, you publish messages out to a hub and it is up to the module to decide how to react to the message.
At least it is at one place to modify and debug. This is loosely coupled. You can easily decide how to react based upon messages. Very easy to introduce new workflows or use cases.
> We have a global live-bound object that holds the session data.
Looks like you are sitting on something that is waiting to explode soon. Global objects are evil