Dojo how to: publish / subscribe
elshawwa.blogspot.com
elshawwa.blogspot.com
This is extremely powerful in the context of UI development because it breaks the concepts of a controller in the MVC anti-pattern that is responsible for so much spaghetti code. It promotes loose coupling among components so that they can be dropped into a page and auto-wire themselves into the ecosystem that is the page.
For example one can write a edit account widget that upon completion, broadcasts an updated account object. Any widgets on the page that display account information or that do processing on an account can subscribe to the account updated publication and receive the new object or data set. Further a web service service client can be wired to listen for it and publish the information back to a server in which the server can syndicate it to other clients.
The beauty of this style development is: yank out the edit account widget and nothing happens. Due to the loose coupling components can be added and removed with 100% certainty of no side effects to peripheral components.
Further, done correctly it eliminates the need for the concept of a controller, widgets become self encapsulated entities, service calls become self encapsulated routines, each and every routine has a clear entry and exit, with no coupling to other code. Thereby making adding new features and debugging drop deal simple.