My team is using the pub sub pattern for a large one page app Point of Sale system at work. We started the app before generics were introduced into typescript so a few of us are pondering the ways we can benefit from strongly typed messages and or call backs within our pattern.
Working version: http://jsfiddle.net/TheDev6/LjuXu/
Some good reading.
http://msdn.microsoft.com/en-us/magazine/hh201955.aspxI'm happy to report that this made it into production on our Single Page App. It seems to have cleared up some code but there is still a long way to go. I wouldn't rest here though and be warned that type script can 'hide' the real nature of javascript. This simply enforces the proper use of a function where applicable.
Thanks for the pub/sub example. The one I'm currently using was extremely basic, and did not have type safety for the message being published/subscribed.
I'm glad this code is useful! Be sure to also search for the latest pub sub libraries as well since it seems like a new one comes out every week that does something really cool.