Just a small post to announce I have added, and finally documented, TinyMessenger to the TinyIoC project.
TinyMessenger provides an event aggregator/messenger for loosely coupled communication. Some scenarios where this may prove useful :
- Communication between Controllers/ViewModels.
- Service classes raising “events”.
- Removing responsibilities from classes that receive external events (such as the AppDelegate in an iPhone application).
- Decoupling communication between classes.
TinyMessenger uses a Publish/Subscribe model and is orderless, so you can subscribe to a message even if there’s nobody publishing, and you can publish one even if nobody is subscribed. It is also loosely coupled in that the publisher and subscriber know nothing of each other, all they both care about is the message itself. Some of the key features are:
- Simple and orderless Publish/Subscribe API.
- Messages either need to implement a simple “marker” interface, or they can build on the “base” classes that are in the box (TinyMessageBase and GenericTinyMessage<TContent>.
- Subscriptions can supply an optional filter – only message that “pass” the filter are delivered.
- Subscriptions can supply an optional “proxy”. A proxy can be used for marshalling to the ui thread, logging or many other purposes.
- Subscriptions use weak references by default, but strong references can be specified if required.