tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/5301-detain-commandsRobotlegs: Discussion 2014-01-24T12:35:22Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/312618182014-01-23T14:06:11Z2014-01-23T14:06:11ZDetain Commands<div><p>Hi Yiotis,</p>
<p>Your post landed into the spam folder of the forum, for unknown
reasons.</p>
<p>As far as I know only the DirectCommandMapExtension has detain
and release.<br>
[<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/directCommandMap">https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]</p>
<p>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.<br>
In this extension you could do something like this:</p>
<pre>
<code>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
{
_context.detain(event.instance);
}
private function release (event:PinEvent):void
{
_context.release (event.instance);
}</code>
</pre>
<p>PinEvent is provided by the framework, but you can use your own
custom event instead.<br>
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.</p>
<p>Hope that helps.<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/312618182014-01-23T21:55:23Z2014-01-23T21:55:24ZDetain Commands<div><p>Thanks Ondina,</p>
<p>I will look into it!</p></div>Yiotis Katsambastag:robotlegs.tenderapp.com,2009-10-18:Comment/312618182014-01-24T12:35:21Z2014-01-24T12:35:21ZDetain Commands<div><p>No problem:)</p></div>Ondina D.F.