Giter VIP home page Giter VIP logo

robotlegs-framework's Introduction

WARNING

Robotlegs 2 is under active development. Developers are encouraged to download the stable Robotlegs 1 release from: http://www.robotlegs.org/

The source for Robotlegs 1 can be found in the master branch:

https://github.com/robotlegs/robotlegs-framework/tree/master

Robotlegs

Robotlegs is an ActionScript application framework for Flash and Flex. It offers:

  • Dependency management
  • Module management
  • Command management
  • View management

Quickstart

Creating A Context

To create a Robotlegs application or module you need to instantiate a Context. A context won't do much without some configuration.

Plain ActionScript:

_context = new Context()
    .extend(MVCSBundle)
    .configure(MyAppConfig, this);

Note: We pass the instance "this" through to the context. It will be used as the "contextView" which is required by many of the view related extensions. It must be installed after the bundle or it won't be processed. Also, you must hold on to the context instance or it will be garbage collected.

Flex:

<fx:Declarations>
    <rl2:ContextBuilder>
        <mvcs:MVCSBundle/>
        <config:MyAppConfig/>
    </rl2:ContextBuilder>
</fx:Declarations>

Note: In Flex we don't need to manually provide a "contextView" as the builder can determine this automatically.

Application & Module Configuration

A simple configuration might look something like this:

public class MyAppConfig
{
    public function MyAppConfig(mediatorMap:IMediatorMap)
    {
        mediatorMap.mapType(SomeView).toMediator(SomeMediator);
    }
}

The configuration file above is a plain class. An instance of this class will be created automatically when the context initializes. Notice that we are using constructor injection to gain access to the mediator map inside our constructor.

WARNING: The config above will not work when using declarative configuration in Flex. For Flex configs that you intend to add directly to the ContextBuilder you have to use setter injection.. Read on.

If you want to use setter injection you must use a [PostConstruct] tag in your config to ensure that all your dependencies have been injected before you start interacting with them:

public class MyAppConfig
{
    [Inject]
    public var mediatorMap:IMediatorMap;

    [PostConstruct]
    public function init():void
    {
        // OK, ready to rock
        mediatorMap.mapView(SomeView).toMediator(SomeMediator);
    }
}

Dependencies supplied via setter injection are not available until after construction, and attempting to access them will result in Null Pointer exceptions. This is wrong:

public class MyErroneousAppConfig
{
    [Inject]
    public var mediatorMap:IMediatorMap;

    public function MyErroneousAppConfig()
    {
        // ERROR: the mediatorMap property will not have been set yet!
        mediatorMap.mapView(SomeView).toMediator(SomeMediator);
    }
}

Reading The Source

Start here:

  • src/robotlegs/readme

Robotlegs 2 - What's New?

Robotlegs 2 is a complete rewrite of the Robotlegs framework. It features:

  • Better configuration
  • Better extension
  • Better module support
  • Flexible type matching

Robotlegs 1 vs Robotlegs 2

RL1 Design Priorities

  1. Small
  2. Fast

RL2 Design Priorities

  1. Flexible
  2. Small
  3. Fast

Building and Running the Tests

Requirements

Whilst Robotlegs can be used for Flex 3 & 4 and plain ActionScript projects, the library must be built with the Flex 4.6 SDK or above.

Using ANT

ant package

Using Ruby on OSX

  • Install XCode 3 or 4

  • check RubyGems version

    $ gem -v 1.8.1

  • update RubyGems if version is less than 1.3.6

    $ sudo gem update --system

  • install Bundler

    $ sudo gem install bundler

  • run Bundler to install dependencies

    $ bundle install

  • run Buildr to build RobotLegs & run Tests

    $ bundle exec buildr test

  • open test report

    $ open reports/flexunit4/html/index.html

Example output of this process

robotlegs-framework's People

Contributors

darscan avatar stray avatar joelhooks avatar tschneidereit avatar devboy avatar jjgonecrypto avatar imcotton avatar simongregory avatar drewbourne avatar probertson avatar texastoland avatar destroytoday avatar seanhess avatar zackpierce avatar

Stargazers

EVelikij avatar

Watchers

James Cloos avatar EVelikij avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.