Archive for the ‘signals’ tag
foomonger-swizframework Updated With Swiz 1.0.0 RC1
Swiz 1.0.0 RC1 was recently released so I've updated my custom metadata processors to work with it. Head over to Google Code to check out [MediateSignal] and [Resource]. Happy coding...
Swiz, Signals, and [MediateSignal]
Joel Hooks created this RobotLegs/Signals demo. Ben Clinkinbeard then created this Swiz-version of Joel's demo. I then took Ben's demo and Swiz-ified it even more by using a custom [MediateSignal] processor. Here's the source.
[MediateSignal] is the Signal equivalent of [Mediate]. Here's an example:
[MediateSignal("galleryUpdatedSignal")] public function galleryUpdated(gallery:Gallery):void
[MediateSignal] takes a Signal Bean name or type and adds the decorated method to the Signal (see GalleryThumbnailsPresentationModel for examples).
This is what I changed from Ben's demo:
- Created the MediateSignalProcessor
- Added [MediateSignal] metadata to the Signal listeners
- Made the Signal listeners public
- Named the Signal Beans
- Removed [PostConstruct] methods that added the Signal listeners
- Removed injected Signals that weren't being using to dispatch
[MediateSignal] makes using Signals in Swiz very parallel to using Events (especially if you define the Event dispatcher as a Bean and inject it by name). And just like Events, you only need to [Inject] the Signals into Beans who are dispatching Signals. I was pretty excited to create my first custom processor and play with Signals for the first time. Let me know what you think!
Disclaimer: I set up MediateSignalProcessor to also handle DeluxeSignals and remove listeners, though to be honest I didn't test those.
* Update: I've posted the processor on Google Code and it contains unit tests (including DeluxeSignals and removing listeners).
** Update: I've created a bare-bones example application: SWF and Source.