Skip to content

Commit

Permalink
updated to use latest version of command executor
Browse files Browse the repository at this point in the history
  • Loading branch information
creynders committed Apr 8, 2013
1 parent bb7a71c commit 7ed2680
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

package robotlegs.bender.extensions.signalCommandMap.api
{
import robotlegs.bender.extensions.commandCenter.api.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.api.ICommandUnmapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandUnmapper;



/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
package robotlegs.bender.extensions.signalCommandMap.impl
{
import org.swiftsuspenders.Injector;
import robotlegs.bender.extensions.commandCenter.api.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.api.ICommandTrigger;
import robotlegs.bender.extensions.commandCenter.api.ICommandUnmapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandUnmapper;
import robotlegs.bender.extensions.commandCenter.impl.CommandTriggerMap;
import robotlegs.bender.extensions.signalCommandMap.api.ISignalCommandMap;
import robotlegs.bender.framework.api.IContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ package robotlegs.bender.extensions.signalCommandMap.impl
import org.osflash.signals.ISignal;
import org.swiftsuspenders.Injector;
import robotlegs.bender.extensions.commandCenter.api.ICommandExecutor;
import robotlegs.bender.extensions.commandCenter.api.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.api.ICommandMapping;
import robotlegs.bender.extensions.commandCenter.api.ICommandMappingList;
import robotlegs.bender.extensions.commandCenter.api.ICommandTrigger;
import robotlegs.bender.extensions.commandCenter.impl.CommandExecutor;
import robotlegs.bender.extensions.commandCenter.impl.CommandMapper;
import robotlegs.bender.extensions.commandCenter.impl.CommandMappingList;
import robotlegs.bender.extensions.commandCenter.impl.CommandPayloadConfig;
import robotlegs.bender.framework.api.ILogger;

/**
Expand All @@ -35,10 +33,10 @@ package robotlegs.bender.extensions.signalCommandMap.impl

private var _injector:Injector;

private var _sandbox:Injector;

private var _mappings:CommandMappingList;

private var _executor:ICommandExecutor;

/*============================================================================*/
/* Constructor */
/*============================================================================*/
Expand All @@ -51,10 +49,12 @@ package robotlegs.bender.extensions.signalCommandMap.impl
signalClass:Class,
logger:ILogger = null)
{
//not .createChildInjector, since the signal instances must be mapped system-wide
_injector = injector;
_sandbox = injector.createChildInjector();

_signalClass = signalClass;
_mappings = new CommandMappingList(this, logger);
_executor = new CommandExecutor(injector.createChildInjector(), _mappings.removeMapping);
}

/*============================================================================*/
Expand Down Expand Up @@ -100,22 +100,8 @@ package robotlegs.bender.extensions.signalCommandMap.impl

private function routeSignalToCommands(... valueObjects):void
{
const valueClasses:Array = _signal.valueClasses;
const executor:ICommandExecutor = new CommandExecutor(_mappings, _sandbox)
.withPayloadMapper(function():void {
for (var i:uint = 0; i < valueClasses.length; i++)
{
_sandbox.map(valueClasses[i]).toValue(valueObjects[i]);
}
})
.withPayloadUnmapper(function():void {
for (var i:uint = 0; i < valueClasses.length; i++)
{
_sandbox.unmap(valueClasses[i]);
}
});

executor.execute();
const payload:CommandPayloadConfig = new CommandPayloadConfig(valueObjects, _signal.valueClasses);
_executor.execute(_mappings.getList(), payload);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ package robotlegs.bender.extensions.signalCommandMap.impl
import org.hamcrest.object.instanceOf;
import org.hamcrest.object.notNullValue;
import org.swiftsuspenders.Injector;
import robotlegs.bender.extensions.commandCenter.api.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.api.ICommandUnmapper;

import robotlegs.bender.extensions.commandCenter.dsl.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandUnmapper;
import robotlegs.bender.extensions.signalCommandMap.api.ISignalCommandMap;
import robotlegs.bender.extensions.signalCommandMap.support.NullCommand;
import robotlegs.bender.extensions.signalCommandMap.support.NullSignal;
Expand Down Expand Up @@ -65,7 +66,7 @@ package robotlegs.bender.extensions.signalCommandMap.impl
[Test]
public function test_unmap_returns_unmapper():void
{
var mapper:ICommandMapper = signalCommandMap.map(NullSignal);
var mapper:ICommandUnmapper = signalCommandMap.unmap(NullSignal);
assertThat(mapper, instanceOf(ICommandUnmapper));
}

Expand Down

0 comments on commit 7ed2680

Please sign in to comment.