Git Product home page Git Product logo

robotlegs-framework's Introduction

Robotlegs

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

  • Dependency injection
  • Module management
  • Command management
  • View management
  • Plug-and-play extensions

Download

http://www.robotlegs.org/

Documentation & Support

The framework documentation exists as README files in the repository. The best way to read them is through GitHub:

Documentation

Support

Developed with pleasure using IntelliJ IDEA

Robotlegs 2 (What's New?)

  • The fluent API makes your code more readable
  • An extension mechanism makes the framework highly customizable
  • Bundles allow you to get applications started quickly
  • Lightweight, built-in logging shows you what the framework is doing
  • Mediators can be mapped to abstract types and interfaces
  • View processing has been significantly optimized
  • A context can process more than one display list (PopUp support)
  • Greatly simplified module (multi-context) support

Change log

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()
    .install(MVCSBundle)
    .configure(MyAppConfig, SomeOtherConfig)
    .configure(new ContextView(this));

We install the MVCSBundle, which in turn installs a number of commonly used Extensions. We then add some custom application configurations.

We pass the instance "this" through 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, it should always be added as the final configuration as it may trigger context initialization.

Note: 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.

Framework

Context Initialization

If a ContextView is provided the Context is automatically initialized when the supplied view lands on stage. Be sure to install the ContextView last, as it may trigger context initialization.

If a ContextView is not supplied then the Context must be manually initialized.

_context = new Context()
    .install(MyCompanyBundle)
    .configure(MyAppConfig, SomeOtherConfig)
    .initialize();

Note: This does not apply to Flex MXML configuration as the ContextView is automatically determined and initialization will be automatic.

ContextView

Application & Module Configuration

A simple application configuration file might look something like this:

public class MyAppConfig implements IConfig
{
    [Inject]
    public var injector:IInjector;

    [Inject]
    public var mediatorMap:IMediatorMap;

    [Inject]
    public var commandMap:IEventCommandMap;

    [Inject]
    public var contextView:ContextView;

    public function configure():void
    {
        // Map UserModel as a context enforced singleton
        injector.map(UserModel).asSingleton();

        // Create a UserProfileMediator for each UserProfileView
        // that lands inside of the Context View
        mediatorMap.map(UserProfileView).toMediator(UserProfileMediator);

        // Execute UserSignInCommand when UserEvent.SIGN_IN
        // is dispatched on the context's Event Dispatcher
        commandMap.map(UserEvent.SIGN_IN).toCommand(UserSignInCommand);

        // The "view" property is a DisplayObjectContainer reference.
        // If this was a Flex application we would need to cast it
        // as an IVisualElementContainer and call addElement().
        contextView.view.addChild(new MainView());
    }
}

The configuration file above implements IConfig. An instance of this class will be created automatically when the context initializes.

We Inject the utilities that we want to configure, and add our Main View to the Context View.

Framework

An Example Mediator

The mediator we mapped above might look like this:

public class UserProfileMediator extends Mediator
{
    [Inject]
    public var view:UserProfileView;

    override public function initialize():void
    {
        // Redispatch an event from the view to the framework
        addViewListener(UserEvent.SIGN_IN, dispatch);
    }
}

The view that caused this mediator to be created is available for Injection.

MediatorMap

An Example Command

The command we mapped above might look like this:

public class UserSignInCommand extends Command
{
    [Inject]
    public var event:UserEvent;

    [Inject]
    public var model:UserModel;

    override public function execute():void
    {
        if (event.username == "bob")
            model.signedIn = true;
    }
}

The event that triggered this command is available for Injection.

EventCommandMap

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.

Building with ANT

Copy the "user.properties.eg" file to "user.properties" and edit it to point to your local Flex SDK. Then run:

ant package

Building with Maven

See: Maven-README

Building with Buildr 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 1

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

Robotlegs Version 1 Branch

robotlegs-framework's People

Contributors

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

Stargazers

Angus H. avatar Fabian Wulf avatar jaason meyer avatar Kelvin avatar Ivan avatar vincent avatar  avatar Robb avatar Tom Liang avatar  avatar cory avatar  avatar 朱光育 avatar  avatar Nahuel Alejandro Ramos avatar alan_langlois avatar Gavin avatar Michal Polkowski avatar  avatar Marcus Brose avatar Yury Timofeev avatar  avatar  avatar Chaffee avatar 京野男爵 avatar riugduso avatar David Ostermann avatar EVelikij avatar William Thivierge avatar Alexey A. Taran avatar farwmarth avatar eisakuu avatar Jared avatar fangs avatar Raimundas Banevicius avatar  avatar Ken Rogers avatar Gun.io Robot avatar  avatar  avatar Tolga Akyuz avatar Angela Relle avatar Hogan Lee avatar Michael Oddis avatar Gabor Szalatnyai avatar George avatar Ciprian Caba avatar Sébastien Cunin avatar  avatar Lynnhom Xue avatar ranke avatar banwenxiaoyu avatar Wade Roberts avatar Andy Cai avatar  avatar Bird avatar Sun Pengju avatar Richard Bausek avatar Dejan Dragic avatar Jesse Warden avatar Andy P avatar Atul Kshirsagar avatar Brian Lewis avatar Jia Jia avatar Andres Lozada Mosto avatar Bruno Dias avatar Justin avatar Heidi López avatar Jean-Baptiste PIN avatar hiso avatar Raed Atoui avatar  avatar  avatar Peter Cardwell-Gardner avatar Gwenn Guihal avatar  avatar Daniel Swid avatar  avatar Jeremy Ruppel avatar Piggyi avatar neil manuell avatar Jamie Owen avatar Ryan.Cao avatar  avatar  avatar Brent Arndorfer avatar Tomasz Maciąg avatar Lamar Hines avatar Benjamin Borowski avatar  avatar Jason Dias avatar  avatar Mike Cann avatar Pascal Van Hecke avatar Maksymilian Chmiel avatar Stefan avatar Owen Corso avatar Benoit Jadinon avatar Alexander de Haas avatar Bram Swenson avatar

Watchers

orcsor avatar James Cloos avatar  avatar  avatar Raimundas Banevicius avatar  avatar Ivan avatar 朱光育 avatar  avatar Chaffee avatar  avatar sunny avatar  avatar  avatar cory avatar  avatar  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.