Code in this post can be obsolete, however, principles and theory may still apply.
Recently I've been looking for a better way of inter-component communication in Ext so I've read a couple of posts with Message Bus implementations, I've skimmed over OpenAjax Hub page but I haven't found anything suitable for my needs.
The first approach was the Simple Message Bus example but that is more concept proof than a really usable way in production environment.
I like the concept of message subjects (topics) as dot separated sequence of tokens with the ability to subscribe to messages with specific subjects and with wildcard support.
For example, if a component would subscribe to the subject eu.extjs.desktop.** it would receive message with subject eu.extjs.desktop.wallpaper.set but it wouldn't receive message eu.extjs.taskbar.hide.
So this plugin was born.
Ext.ux.MsgBus fits in any component that is descendant of Ext.util.Observable and it does not need any other changes/overrides. You would stick it only into the components that must participate in bus messaging. It adds subscribe and publish methods to the component.
Usage example:
The above would call p.onWallpaper callback once upon the receipt of a "wallpaper" message. Other example:
I haven't tested it fully yet so take it more as an initial idea than as a bullet-proof, worldwide-tested code. Also, I didn't try in any means to implement OpenAjax standards and use this plugin for an inter library communication. Consider it as a one possibility of intra-Ext, inter-component communication. Any comments and/or bug reports are welcome.
Enjoy! The accompanying example is no longer online.



28 comments
Comments are closed on archived posts.