Detailed information on the upcoming release of Robotlegs, the lightweight micro-architecture for Flash (AS3) applications with modular IOC, contractual mediation and a fluent interface.
protected var _contextView:DisplayObjectContainer; protected var _commandMap:ICommandMap; protected var _mediatorMap:IMediatorMap; protected var _viewMap:IViewMap; } Contexts in robotlegs circa v1 Thursday, 27 October 11
class Container { private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing; protected var sureYouCanOverrideMe:ButYouAintGettingRidOfMe; } Thursday, 27 October 11
function anyOf(... params):TypeMatcher; function noneOf(... params):TypeMatcher; function allOf(... params):TypeMatcher; } new TypeMatcher() .allOf(ISpaceShip, IEnemy) .noneOf(DeathStar) Usage Definion Thursday, 27 October 11
possible use-cases for a guard: • prevent mediation when ... • prevent command execution when ... mediatorMap .map(UserDetailsMediator) .withGuard(UserIsAdminGuard) .toView(IUserDetailsAware); Thursday, 27 October 11
//creates a new instance per injection injector.map(SomeType); //or injector.map(SomeType, ‘named’); //create new instance per injection and map to injector.map(IService).toType(SomeService); //or value .toValue(someInstance) //map as singleton instance injector.map(SomeService).asSingleton(); //or .toSingleton(SomeService); //allows to easily specify custom providers to use for a mapping injector.map(IService).toProvider(new CustomProvider()); //prevents sharing the mapping with child injectors; injector.map(SomeService).local(); // .shared() reverts it //allow child injector to map if none exists injector.map(SomeService).soft(); // .strong() maps regardless //prevents changes to the mapping; returns a unique key object injector.map(SomeService).seal(); //can revert with key and .unseal() Thursday, 27 October 11
context wired up by parent once added to stage • view events are collated in the one view manager • child injectors created and wired to the parent • default injections to ensure modules work both standalone and when integrated. Thursday, 27 October 11
IEventDispatcher and there’s no enforcement of contract. import flash.events.IEventDispatcher; [Event(name="doAsync", type="...ControlEvent")] public interface IServiceStarter extends IEventDispatcher { function serviceReturned():void; } Thursday, 27 October 11
start():ISignal; } with signals, we define the contract import org.osflash.signals.ISignal; private var startSignal:ISignal = new Signal(); public function serviceReturned():void { Alert.show("The service returned.","Guess what?"); } public function get start():ISignal { return startSignal; } ... <s:Button label=”Start” click=”start.dispatch” /> and force the view to comply Thursday, 27 October 11