RL2
ActionScript Application Framework




            Dot Brighton - 2012      1
hello, I’m
                            shaun
                            smith

                            @darscan
                            #robotlegs
http://shaun.boyblack.co.za/blog/about/   2
RL1 Recap
             Dependency Injection
                     Commands
                      Mediators




https://github.com/robotlegs/robotlegs-framework/tree/master   3
RL2
                As above, but with:


                     A fluent API
               Extensions (opt-in)
                Bundles (presets)
                        Configs
                 Logging (built-in)
                Module autowiring

https://github.com/robotlegs/robotlegs-framework/tree/version2   4
Dependency Injection


   https://github.com/tschneidereit/SwiftSuspenders/   5
Swiftsuspenders 2

injector.map(IService).toValue(service)
injector.map(IService).toType(SomeService)
injector.map(IService).toSingleton(SomeService)
injector.map(SomeService).asSingleton()


                             Faster
                Local vs shared scopes
                 Hard vs soft mappings


          https://github.com/tschneidereit/SwiftSuspenders/   6
Context & Startup


     framework/readme-context.md   7
context = new Context()
 .extend(MVCSBundle)
 .configure(MyAppConfig, this);


No more extend and override
Opt-in extensions
Convenient, shareable bundles
Conventions for configuration
Consolidated startup process


           framework/readme-context.md   8
Commands

  extensions/eventCommandMap   9
eventCommandMap
.map(SomeEvent.EVENT, SomeEvent)
.toCommand(MyCommand)
.once();




           extensions/eventCommandMap   10
Mediators

  extensions/mediatorMap   11
mediatorMap
 .map(SomeType)
 .toMediator(SomeMediator)


Can map to interfaces and abstract types
Possibly many mediators per view
Nested stage listener optimisations




              extensions/mediatorMap       12
Configs

 framework/readme-context.md   13
context = new Context()
 .extend(MVCSBundle)
 .configure(MyAppConfig, this);




          framework/readme-context.md   14
class ViewConfig
{
    public function ViewConfig(mediatorMap:IMediatorMap)
    {

        mediatorMap.map(SomeView)
            .toMediator(SomeMediator);
    }
}




                       framework/readme-context.md        15
class MyModuleConfig implements IConfig
{
    [Inject]
    public var mediatorMap:IMediatorMap;

    public function configure():void
    {
        mediatorMap.map(SomeView)
          .toMediator(SomeMediator);
    }
}


                  framework/readme-context.md   16
Extensions

    extensions   17
public class EventCommandMapExtension
    implements IExtension
{
    public function extend(context:IContext):void
    {
        context.injector
         .map(IEventCommandMap)
         .toSingleton(EventCommandMap);
    }
}



                           extensions/eventCommandMap   18
Extensions are installed immediately:

      context.extend(MyExtension)
                   ~=
    new MyExtension().extend(context)




                 extensions             19
Bundles

  bundles   20
context = new Context()
 .extend(MVCSBundle)
 .configure(MyAppConfig, this);




                 bundles        21
public class MVCSBundle implements IBundle
{
    public function extend(context:IContext):void
    {
        context.extend(
         ModularityExtension,
         EventCommandMapExtension,
         ... etc ...
         MediatorMapExtension,
         StageSyncExtension);
        context.configure(ContextViewListenerConfig);
    }
}

                                bundles/mvcs          22
Bundles are installed immediately:

      context.extend(MyBundle)
                ~=
   new MyBundle().extend(context)




               bundles               23
Bundles vs Extensions


         extensions     24
An extension integrates a single utility or library with a
                 Robotlegs context


    A bundle installs a selection of extensions and
       configurations into a Robotlegs context




                         extensions                          25
Logging

 framework/readme-logging.md   26
Lightweight logging system built in: context.getLogger(MyClass)


                 Optional logging extensions

LoggingExtension: allows you to [Inject] public var logger:ILogger;


InjectorLoggingExtension: logs injection events (not 4 production!)


TraceLoggingExtension: simple trace log target




                          extensions/logging                          27
Demos

 github urls to follow   28
https://github.com/darscan/robotlegs-demos-HelloFlash


https://github.com/darscan/robotlegs-demos-HelloFlex


https://github.com/darscan/robotlegs-demos-Todo




                      github.com                        29
Thanks!

https://github.com/robotlegs/robotlegs-framework   30
Questions?

             31

RL2 Dot Brighton