Detain Commands

Yiotix's Avatar


23 Jan, 2014 02:04 AM

I am transitioning over to Robotlegs2 and just curious.. (I like RL2 btw.. nice work!)
Do I have to context.detain/release commands that are waiting for an async process?
Do I really have to inject the context for every command?


  1. Support Staff 1 Posted by Ondina D.F. on 23 Jan, 2014 02:06 PM

    Ondina D.F.'s Avatar

    Hi Yiotis,

    Your post landed into the spam folder of the forum, for unknown reasons.

    As far as I know only the DirectCommandMapExtension has detain and release.

    For the common commands you could create an extension (implementing IExtension) that you install when you create a context. Look at other robotlegs extensions to get an idea about how to create one.
    In this extension you could do something like this:

    public function extend(context:IContext):void
        _context = context;
        _injector = context.injector;
        _eventDispatcher = _injector.getInstance(IEventDispatcher);
        _eventDispatcher.addEventListener(PinEvent.DETAIN, detain);
        _eventDispatcher.addEventListener(PinEvent.RELEASE, release);
    private function detain(event:PinEvent):void
    private function release (event:PinEvent):void
        _context.release (event.instance);

    PinEvent is provided by the framework, but you can use your own custom event instead.
    In your command you can dispatch a PinEvent.DETAIN or PinEvent.RELEASE on the shared event dispatcher, or you put this functionality into a base class that the command would extend and you call its methods, which you can name detain and release, if you want to.

    Hope that helps.

  2. 2 Posted by Yiotis Katsamba... on 23 Jan, 2014 09:55 PM

    Yiotis Katsambas's Avatar

    Thanks Ondina,

    I will look into it!

  3. Support Staff 3 Posted by Ondina D.F. on 24 Jan, 2014 12:35 PM

    Ondina D.F.'s Avatar

    No problem:)

  4. Ondina D.F. closed this discussion on 24 Jan, 2014 12:35 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac