An Event Command Map executes commands in response to events on a given Event Dispatcher.
eventCommandMap
.map(SignOutEvent.SIGN_OUT, SignOutEvent)
.toCommand(SignOutCommand);
eventDispatcher.dispatchEvent(new SignOutEvent(SignOutEvent.SIGN_OUT));
Note: for a less verbose and more performant command mechanism see the MessageCommandMap extension.
This extension requires the following extensions:
- CommandMapExtension
- EventDispatcherExtension
_context = new Context().extend(
CommandCenterExtension,
EventDispatcherExtension,
EventCommandMapExtension);
Or, assuming that the EventDispatcher and CommandCenter extensions have already been installed:
_context.extend(EventCommandMapExtension);
An instance of IEventCommandMap is mapped into the context during extension installation. This instance can be injected into clients and used as below.
[Inject]
public var eventCommandMap:IEventCommandMap;