SlideShare a Scribd company logo
1 of 136
robotlegs
robotlegs 2.0
the goals
configurable
 because every project is unique
versatile
    rigidity sucks
concise
use only what you need
fluent
make(tea).with(milk).butNot(sugar)
govt health warning
these examples are subject to change
the features
.context builder
Contexts in robotlegs circa v1
Contexts in robotlegs circa v1
public 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;
}
public class Container
{
   private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing;

    protected var sureYouCanOverrideMe:ButYouAintGettingRidOfMe;
}
public class Container
{
   private var youCantSeeMe:SoLetsHopeIKnowWhatImDoing;

    protected var sureYouCanOverrideMe:ButYouAintGettingRidOfMe;
}




in version one,
features were bound to the context.
RL2 contexts are created with what you need
                          not extended with what you don’t
Introducing the context builder
Introducing the context builder
public 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;
}
.withConfig
.withConfig
public interface IContextConfig
{
   function configure(context:IContext):void;
}




setup your configuration to execute once at build.
.withExtension
.withExtension
public interface IContextExtension
{
	 function initialize(context:IContext):void;

	   function install(context:IContext):void;

	   function uninstall(context:IContext):void;
}




extensions add functionality at any time.
.withProcessor
.withProcessor
public interface IContextProcessor
{
	 function process(context:IContext, callback:Function):void;
}




processors asynchronously affect the build state.
.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
 views
when you simply can’t live without view injection.
.type matching
Definion
Definion
public class   TypeMatcher
{
    function   anyOf(... params):TypeMatcher;
    function   noneOf(... params):TypeMatcher;
    function   allOf(... params):TypeMatcher;
}


Usage
new TypeMatcher()
  .allOf(ISpaceShip, IEnemy)
  .noneOf(DeathStar)




flexible and fluent type matching syntax
.view management
viewManager.addContainer(contextView);
	    viewManager.addHandler(mediatorMap);
	    viewManager.addWatcher(stageWatcher);
 	   viewManager.addContainer(myPopUp);

     wire view handlers to view watchers
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.
.mediate anything
mediatorMap.map(UserDetailsMediator).toView(IUserDetailsAware);

            map mediators to interfaces rather than
                                 concrete classes.
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
.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(UserDetailsMediator)
   .toView(IUserDetailsAware)
	 .withGuard(UserIsAdminGuard);




a guard represents conditional logic for an
action to occur.
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 execution
scenarios for using a hook:
• customised logging
• view skinning

• view localisation

• instance configuration prior to command execution


commandMap
	 .map(UserLoginCommand)
   .toEvent(UserLoginEvent.LOGIN, UserLoginEvent)
	 .withHook(ConfigureUserDetails)
scenarios for using a hook:
• customised logging
• view skinning

• view localisation

• instance configuration prior to command execution


commandMap
	 .map(UserLoginCommand)
   .toEvent(UserLoginEvent.LOGIN, UserLoginEvent)
	 .withHook(ConfigureUserDetails)



a hook enables pre-processing on an action.
.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 commands




a rule can prevent or ensure an action’s occurrence.
command flows:
command flows:
create a workflow of commands to represent a
complex sequence
command flows:
create a workflow of commands to represent a
complex sequence




flows are pathways between commands
.swift-suspenders integration
//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()



full integration with swift suspenders 2
leverages the entire toolkit.
.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 view manager
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
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 both
standalone and when integrated.
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 both
standalone and when integrated.




in robotlegs 2, modules just work.
.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 comparison
let’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




             one mediator per view.
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
•   no reuse of mediation
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


                             IBehaviour B


                  IBehaviour C
covariant mediation (via interfaces)



                        View
   Mediator A

                   IBehaviour A


                             IBehaviour B


                   IBehaviour C             Mediator B



      Mediator C
covariant mediation (via interfaces)



                        View
   Mediator A

                   IBehaviour A


                             IBehaviour B


                   IBehaviour C             Mediator B



      Mediator C
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
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.
what is wrong with this contract?
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.
.enter signals, stage right
with signals, we define the contract
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” />
with covariance and signals
with covariance and signals


                      View

                 IBehaviour A


                           IBehaviour B


                 IBehaviour C
with covariance and signals


                            View
   Mediator A

                       IBehaviour A


                                 IBehaviour B


                       IBehaviour C             Mediator B




          Mediator C
with covariance and signals


                            View
   Mediator A

                       IBehaviour A


                                 IBehaviour B


                       IBehaviour C             Mediator B




          Mediator C
with covariance and signals


                            View
   Mediator A

                       IBehaviour A


                                 IBehaviour B


                       IBehaviour C             Mediator B




          Mediator C




      each view is mediated bidirectionally.
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
so when is robotlegs 2
             coming?
...now.
as of this afternoon
robotlegs 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

  Follow @robotlegs_as3 on Twitter.
fin.
about.me/justinj
@justinjmoses

More Related Content

Similar to Introduction to Robotlegs 2

Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
Mahmoud Hamed Mahmoud
 

Similar to Introduction to Robotlegs 2 (20)

Angular VS FORWARD
Angular VS FORWARDAngular VS FORWARD
Angular VS FORWARD
 
Angular vs FORWARD
Angular vs FORWARDAngular vs FORWARD
Angular vs FORWARD
 
Swiz DAO
Swiz DAOSwiz DAO
Swiz DAO
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 
Introducing PanelKit
Introducing PanelKitIntroducing PanelKit
Introducing PanelKit
 
iOS Transition Animations The proper way to do it.pdf
iOS Transition Animations The proper way to do it.pdfiOS Transition Animations The proper way to do it.pdf
iOS Transition Animations The proper way to do it.pdf
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answers
 
Testing view controllers with Quick and Nimble
Testing view controllers with Quick and NimbleTesting view controllers with Quick and Nimble
Testing view controllers with Quick and Nimble
 
mvcExpress training course : part1
mvcExpress training course : part1mvcExpress training course : part1
mvcExpress training course : part1
 
Dependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJS
 
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Riacon swiz
Riacon swizRiacon swiz
Riacon swiz
 
Conductor vs Fragments
Conductor vs FragmentsConductor vs Fragments
Conductor vs Fragments
 
Monorail Introduction
Monorail IntroductionMonorail Introduction
Monorail Introduction
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgets
 
Vue, vue router, vuex
Vue, vue router, vuexVue, vue router, vuex
Vue, vue router, vuex
 
A mysterious journey to MVP world - Viber Android Meetup 2018
A mysterious journey to MVP world - Viber Android Meetup 2018A mysterious journey to MVP world - Viber Android Meetup 2018
A mysterious journey to MVP world - Viber Android Meetup 2018
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 

Introduction to Robotlegs 2

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. uses fluent interface, for readability. think jQuery. each chained method returns context for the next call. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. for example, a Context View Watcher, which waits for ADDED TO STAGE.\n
  18. for example, a Context View Watcher, which waits for ADDED TO STAGE.\n
  19. for example, the View Manager, Stage Watcher, Logging mechanism\n
  20. for example, the View Manager, Stage Watcher, Logging mechanism\n
  21. for example, the Parent Context Finder - the context checks to see if a parent exists during the creation process. \n
  22. for example, the Parent Context Finder - the context checks to see if a parent exists during the creation process. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. show Mediate Classes examples.\n
  87. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  88. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  89. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  90. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  91. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  92. when done, see Mediate Classes &gt; Mediators &gt; console output.\n
  93. \n
  94. \n
  95. \n
  96. show the Mediate Middle example. Show variant mediator map.\n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n