Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

6. The CommandMap in action > Commands know about the injector, command map, me...

Commands know about the injector, command map, mediator map and context view

If you extend the Command base class, you’ll inherit injections for the injector, commandMap and mediatorMap properties that are used in your context, and you’ll get a helper method for dispatching events:

Example 6-3. The Command class gives you access to the main Robotlegs players

public class Command
{
    [Inject]
    public var contextView:DisplayObjectContainer;

    [Inject]
    public var commandMap:ICommandMap;

    [Inject]
    public var eventDispatcher:IEventDispatcher;

    [Inject]
    public var injector:IInjector;

    [Inject]
    public var mediatorMap:IMediatorMap;
    
    public function execute():void
    {
    }

    /**
     * Dispatch helper method
     */
    protected function dispatch(event:Event):Boolean
    {
        if(eventDispatcher.hasEventListener(event.type))
            return eventDispatcher.dispatchEvent(event);
         return false;  
    }
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial