PureMVC Tip: Notifications
Monday, September 29th, 2008This is a somewhat obvious tip, but in the past when sending PureMVC notifications I’ve sent them with an Array as the body. This is nice for simplicity, but requires you to more or less remember what the order of parameters are and what type each is. My solution is simply to create a single value object class for notification bodies (that phrase sounds weird) sending complex data. Then you can cast the body of the notification back to its type and maintain type safety, as well as having access to any code completion.
It’s not an end-all solution, I wouldn’t expend time coding a class for simple notifications, but it certainly helps keep your command code clean and readable when you’re send more complex data.