Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
robotlegs
robotlegs 2.0
the goals
configurable because every project is unique
versatile    rigidity sucks
conciseuse only what you need
fluentmake(tea).with(milk).butNot(sugar)
govt health warningthese examples are subject to change
the features
.context builder
Contexts in robotlegs circa v1
Contexts in robotlegs circa v1public class Context{	 	 protected var _injector:IInjector;	 	 protected var _reflector:IRef...
public class Container{   private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing;    protected var sureYouCanOverrideMe:ButYo...
public class Container{   private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing;    protected var sureYouCanOverrideMe:ButYo...
RL2 contexts are created with what you need                          not extended with what you don’t
Introducing the context builder
Introducing the context builderpublic interface IContextBuilder{  build():IContext;    withBundle(bundle:IContextBuilderBu...
.withConfig
.withConfigpublic interface IContextConfig{   function configure(context:IContext):void;}setup your configuration to execu...
.withExtension
.withExtensionpublic interface IContextExtension{	 function initialize(context:IContext):void;	   function install(context...
.withProcessor
.withProcessorpublic interface IContextProcessor{	 function process(context:IContext, callback:Function):void;}processors ...
.pre-configured bundles
four tasty flavours of robotlegs         each representing a context builder bundle
Original»when plain old vanilla is just right.
light»   when size and performance are paramount.
rapid»when time is of the essence.
» smart viewswhen you simply can’t live without view injection.
.type matching
Definion
Definionpublic class   TypeMatcher{    function   anyOf(... params):TypeMatcher;    function   noneOf(... params):TypeMatc...
.view management
viewManager.addContainer(contextView);	    viewManager.addHandler(mediatorMap);	    viewManager.addWatcher(stageWatcher); ...
viewManager.addContainer(contextView);	    viewManager.addHandler(mediatorMap);	    viewManager.addWatcher(stageWatcher); ...
.mediate anything
mediatorMap.map(UserDetailsMediator).toView(IUserDetailsAware);            map mediators to interfaces rather than        ...
mediatorMap.map(UserDetailsMediator).toView(IUserDetailsAware);              map mediators to interfaces rather than      ...
.guards and hooks
possible use-cases for a guard:
possible use-cases for a guard:•   prevent mediation when ...
possible use-cases for a guard:• prevent mediation when ...• prevent command execution when ...
possible use-cases for a guard:• prevent mediation when ...• prevent command execution when ...mediatorMap	 .map(UserDetai...
scenarios for using a hook:
scenarios for using a hook:•   customised logging
scenarios for using a hook:• customised logging• view skinning
scenarios for using a hook:• customised logging• view skinning• view localisation
scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command...
scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command...
scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command...
.rule sets and command flow
possible uses of a rule:
possible uses of a rule:•   adding or removing mediators
possible uses of a rule:• adding or removing mediators• loading or unloading commands
possible uses of a rule:• adding or removing mediators• loading or unloading commandsa rule can prevent or ensure an actio...
command flows:
command flows:create a workflow of commands to represent acomplex sequence
command flows:create a workflow of commands to represent acomplex sequenceflows are pathways between commands
.swift-suspenders integration
//creates a new instance per injectioninjector.map(SomeType); //or injector.map(SomeType, ‘named’);//create new instance p...
.module integration
integrated module automation:
integrated module automation:•   context wired up by parent once added to stage
integrated module automation:•   context wired up by parent once added to stage•   view events are collated in the one vie...
integrated module automation:•   context wired up by parent once added to stage•   view events are collated in the one vie...
integrated module automation:•   context wired up by parent once added to stage•   view events are collated in the one vie...
integrated module automation:•   context wired up by parent once added to stage•   view events are collated in the one vie...
.robotlegs inspector
new inspector             gadget tool to             help you with             your             robotlegging.info here.
an example in covariance         mediate behaviours not views
for comparison
for comparisonlet’s look at a simple robotlegs v1 application
invariant mediation (via classes)
invariant mediation (via classes)                            View
invariant mediation (via classes)                            View         Mediator
invariant mediation (via classes)                            View         Mediator
invariant mediation (via classes)                    events                             View         Mediator
invariant mediation (via classes)                    events                             View         Mediator             ...
what’s wrong with this approach?
what’s wrong with this approach?•   the mediator is tightly coupled to the view
what’s wrong with this approach?•   the mediator is tightly coupled to the view•   view is restricted to one mediator
what’s wrong with this approach?•   the mediator is tightly coupled to the view•   view is restricted to one mediator•   n...
how to fix this in v1?
how to fix this in v1?using the variance utility
covariant mediation (via interfaces)
covariant mediation (via interfaces)                     View
covariant mediation (via interfaces)                        View                   IBehaviour A                           ...
covariant mediation (via interfaces)                        View   Mediator A                   IBehaviour A              ...
covariant mediation (via interfaces)                        View   Mediator A                   IBehaviour A              ...
covariant mediation (via interfaces)                       e v e n t s                                     View   Mediator...
covariant mediation (via interfaces)                          e v e n t s                                        View   Me...
what is wrong with this contract?
what is wrong with this contract? import flash.events.IEventDispatcher; [Event(name="doAsync", type="...ControlEvent")] pu...
.enter signals, stage right
with signals, we define the contract
with signals, we define the contract  import org.osflash.signals.ISignal;  public interface IServiceStarter  {  	   functi...
with covariance and signals
with covariance and signals                      View                 IBehaviour A                           IBehaviour B ...
with covariance and signals                            View   Mediator A                       IBehaviour A               ...
with covariance and signals                            View   Mediator A                       IBehaviour A               ...
with covariance and signals                            View   Mediator A                       IBehaviour A               ...
to view this sample online go to j.mp/covariance    Libraries used:    •   robotlegs 1.5.2    •   robotlegs variance utili...
so when is robotlegs 2             coming?
...now.
as of this afternoonrobotlegs 2 is in open beta.
Stay updated.
Stay updated.  Add you name to the RL2 beta list by commenting on:  j.mp/robotlegs2  Join the robotlegs google group  Foll...
fin.about.me/justinj@justinjmoses
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Introduction to Robotlegs 2
Upcoming SlideShare
Loading in …5
×

Introduction to Robotlegs 2

23,985 views

Published on

An introduction to the features coming in Robotlegs 2.0 and a discussion of covariance

Published in: Technology
  • Be the first to comment

Introduction to Robotlegs 2

  1. robotlegs
  2. robotlegs 2.0
  3. the goals
  4. configurable because every project is unique
  5. versatile rigidity sucks
  6. conciseuse only what you need
  7. fluentmake(tea).with(milk).butNot(sugar)
  8. govt health warningthese examples are subject to change
  9. the features
  10. .context builder
  11. Contexts in robotlegs circa v1
  12. Contexts in robotlegs circa v1public class Context{ protected var _injector:IInjector; protected var _reflector:IReflector; protected var _contextView:DisplayObjectContainer; protected var _commandMap:ICommandMap; protected var _mediatorMap:IMediatorMap; protected var _viewMap:IViewMap;}
  13. public class Container{ private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing; protected var sureYouCanOverrideMe:ButYouAintGettingRidOfMe;}
  14. public class Container{ private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing; protected var sureYouCanOverrideMe:ButYouAintGettingRidOfMe;}in version one,features were bound to the context.
  15. RL2 contexts are created with what you need not extended with what you don’t
  16. Introducing the context builder
  17. Introducing the context builderpublic interface IContextBuilder{ build():IContext; withBundle(bundle:IContextBuilderBundle):IContextBuilder; withConfig(config:IContextConfig):IContextBuilder; withContextView(value:DisplayObjectContainer):IContextBuilder; withDispatcher(value:IEventDispatcher):IContextBuilder; withExtension(extension:IContextExtension):IContextBuilder; withInjector(value:Injector):IContextBuilder; withParent(value:IContext):IContextBuilder; withProcessor(processor:IContextProcessor):IContextBuilder;}
  18. .withConfig
  19. .withConfigpublic interface IContextConfig{ function configure(context:IContext):void;}setup your configuration to execute once at build.
  20. .withExtension
  21. .withExtensionpublic interface IContextExtension{ function initialize(context:IContext):void; function install(context:IContext):void; function uninstall(context:IContext):void;}extensions add functionality at any time.
  22. .withProcessor
  23. .withProcessorpublic interface IContextProcessor{ function process(context:IContext, callback:Function):void;}processors asynchronously affect the build state.
  24. .pre-configured bundles
  25. four tasty flavours of robotlegs each representing a context builder bundle
  26. Original»when plain old vanilla is just right.
  27. light» when size and performance are paramount.
  28. rapid»when time is of the essence.
  29. » smart viewswhen you simply can’t live without view injection.
  30. .type matching
  31. Definion
  32. Definionpublic class TypeMatcher{ function anyOf(... params):TypeMatcher; function noneOf(... params):TypeMatcher; function allOf(... params):TypeMatcher;}Usagenew TypeMatcher() .allOf(ISpaceShip, IEnemy) .noneOf(DeathStar)flexible and fluent type matching syntax
  33. .view management
  34. viewManager.addContainer(contextView); viewManager.addHandler(mediatorMap); viewManager.addWatcher(stageWatcher); viewManager.addContainer(myPopUp); wire view handlers to view watchers
  35. viewManager.addContainer(contextView); viewManager.addHandler(mediatorMap); viewManager.addWatcher(stageWatcher); viewManager.addContainer(myPopUp); wire view handlers to view watchers viewManager.addContainer(myPopUp); viewManager.addContainer(myAIRWindow); native support for flex popups and air windows.
  36. .mediate anything
  37. mediatorMap.map(UserDetailsMediator).toView(IUserDetailsAware); map mediators to interfaces rather than concrete classes.
  38. mediatorMap.map(UserDetailsMediator).toView(IUserDetailsAware); map mediators to interfaces rather than concrete classes.mediatorMap .map(SomeMenuMediator) .toMatcher() .anyOf(TopLevelMenu, AdminMenu, FootMenu);use type-matching to refine your mapping
  39. .guards and hooks
  40. possible use-cases for a guard:
  41. possible use-cases for a guard:• prevent mediation when ...
  42. possible use-cases for a guard:• prevent mediation when ...• prevent command execution when ...
  43. possible use-cases for a guard:• prevent mediation when ...• prevent command execution when ...mediatorMap .map(UserDetailsMediator) .toView(IUserDetailsAware) .withGuard(UserIsAdminGuard);a guard represents conditional logic for anaction to occur.
  44. scenarios for using a hook:
  45. scenarios for using a hook:• customised logging
  46. scenarios for using a hook:• customised logging• view skinning
  47. scenarios for using a hook:• customised logging• view skinning• view localisation
  48. scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command execution
  49. scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command executioncommandMap .map(UserLoginCommand) .toEvent(UserLoginEvent.LOGIN, UserLoginEvent) .withHook(ConfigureUserDetails)
  50. scenarios for using a hook:• customised logging• view skinning• view localisation• instance configuration prior to command executioncommandMap .map(UserLoginCommand) .toEvent(UserLoginEvent.LOGIN, UserLoginEvent) .withHook(ConfigureUserDetails)a hook enables pre-processing on an action.
  51. .rule sets and command flow
  52. possible uses of a rule:
  53. possible uses of a rule:• adding or removing mediators
  54. possible uses of a rule:• adding or removing mediators• loading or unloading commands
  55. possible uses of a rule:• adding or removing mediators• loading or unloading commandsa rule can prevent or ensure an action’s occurrence.
  56. command flows:
  57. command flows:create a workflow of commands to represent acomplex sequence
  58. command flows:create a workflow of commands to represent acomplex sequenceflows are pathways between commands
  59. .swift-suspenders integration
  60. //creates a new instance per injectioninjector.map(SomeType); //or injector.map(SomeType, ‘named’);//create new instance per injection and map toinjector.map(IService).toType(SomeService); //or value .toValue(someInstance)//map as singleton instanceinjector.map(SomeService).asSingleton(); //or .toSingleton(SomeService);//allows to easily specify custom providers to use for a mappinginjector.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 existsinjector.map(SomeService).soft(); // .strong() maps regardless//prevents changes to the mapping; returns a unique key objectinjector.map(SomeService).seal(); //can revert with key and .unseal()full integration with swift suspenders 2leverages the entire toolkit.
  61. .module integration
  62. integrated module automation:
  63. integrated module automation:• context wired up by parent once added to stage
  64. integrated module automation:• context wired up by parent once added to stage• view events are collated in the one view manager
  65. integrated module automation:• 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
  66. integrated module automation:• 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 bothstandalone and when integrated.
  67. integrated module automation:• 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 bothstandalone and when integrated.in robotlegs 2, modules just work.
  68. .robotlegs inspector
  69. new inspector gadget tool to help you with your robotlegging.info here.
  70. an example in covariance mediate behaviours not views
  71. for comparison
  72. for comparisonlet’s look at a simple robotlegs v1 application
  73. invariant mediation (via classes)
  74. invariant mediation (via classes) View
  75. invariant mediation (via classes) View Mediator
  76. invariant mediation (via classes) View Mediator
  77. invariant mediation (via classes) events View Mediator
  78. invariant mediation (via classes) events View Mediator one mediator per view.
  79. what’s wrong with this approach?
  80. what’s wrong with this approach?• the mediator is tightly coupled to the view
  81. what’s wrong with this approach?• the mediator is tightly coupled to the view• view is restricted to one mediator
  82. what’s wrong with this approach?• the mediator is tightly coupled to the view• view is restricted to one mediator• no reuse of mediation
  83. how to fix this in v1?
  84. how to fix this in v1?using the variance utility
  85. covariant mediation (via interfaces)
  86. covariant mediation (via interfaces) View
  87. covariant mediation (via interfaces) View IBehaviour A IBehaviour B IBehaviour C
  88. covariant mediation (via interfaces) View Mediator A IBehaviour A IBehaviour B IBehaviour C Mediator B Mediator C
  89. covariant mediation (via interfaces) View Mediator A IBehaviour A IBehaviour B IBehaviour C Mediator B Mediator C
  90. covariant mediation (via interfaces) e v e n t s View Mediator A e v e n t s IBehaviour A IBehaviour B e v e n t s IBehaviour C Mediator B Mediator C
  91. covariant mediation (via interfaces) e v e n t s View Mediator A e v e n t s IBehaviour A IBehaviour B e v e n t s IBehaviour C Mediator B Mediator C n mediators per view.
  92. what is wrong with this contract?
  93. what is wrong with this contract? import flash.events.IEventDispatcher; [Event(name="doAsync", type="...ControlEvent")] public interface IServiceStarter extends IEventDispatcher { function serviceReturned():void; }we have to extend IEventDispatcher and there’s no enforcement of contract.
  94. .enter signals, stage right
  95. with signals, we define the contract
  96. with signals, we define the contract import org.osflash.signals.ISignal; public interface IServiceStarter { function serviceReturned():void; function get start():ISignal; } and force the view to comply 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” />
  97. with covariance and signals
  98. with covariance and signals View IBehaviour A IBehaviour B IBehaviour C
  99. with covariance and signals View Mediator A IBehaviour A IBehaviour B IBehaviour C Mediator B Mediator C
  100. with covariance and signals View Mediator A IBehaviour A IBehaviour B IBehaviour C Mediator B Mediator C
  101. with covariance and signals View Mediator A IBehaviour A IBehaviour B IBehaviour C Mediator B Mediator C each view is mediated bidirectionally.
  102. to view this sample online go to j.mp/covariance Libraries used: • robotlegs 1.5.2 • robotlegs variance utility 1.1 • as3-signals 0.9-beta
  103. so when is robotlegs 2 coming?
  104. ...now.
  105. as of this afternoonrobotlegs 2 is in open beta.
  106. Stay updated.
  107. Stay updated. Add you name to the RL2 beta list by commenting on: j.mp/robotlegs2 Join the robotlegs google group Follow @robotlegs_as3 on Twitter.
  108. fin.about.me/justinj@justinjmoses

×