Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 1.08 KB

File metadata and controls

43 lines (25 loc) · 1.08 KB

Event Command Map

Overview

An Event Command Map executes commands in response to events on a given Event Dispatcher.

Basic Usage

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.

Event Command Map Extension

Requirements

This extension requires the following extensions:

  • CommandMapExtension
  • EventDispatcherExtension

Extension Installation

_context = new Context().extend(
	CommandCenterExtension,
	EventDispatcherExtension,
    EventCommandMapExtension);

Or, assuming that the EventDispatcher and CommandCenter extensions have already been installed:

_context.extend(EventCommandMapExtension);

Extension Usage

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;