All Projects → GoodgameStudios → RobotlegsJS

GoodgameStudios / RobotlegsJS

Licence: MIT license
MOVED: This project has moved to https://github.com/RobotlegsJS/RobotlegsJS

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to RobotlegsJS

Browsix
Browsix is a Unix-like operating system for the browser.
Stars: ✭ 2,583 (+6881.08%)
Mutual labels:  javascript-framework
kites
Template-based Web Application Framework
Stars: ✭ 51 (+37.84%)
Mutual labels:  javascript-framework
CoCreateCSS
A lightweight utility-first Atomic CSS framework promoting rapid UI development. No learning curve... Apply your native css property:value directly in class, then extract and transform it.
Stars: ✭ 13 (-64.86%)
Mutual labels:  javascript-framework
Friendup
Friend OS is the Internet Operating System for any device, running on posix compatible hosts. Also known as the Friend Unifying Platform.
Stars: ✭ 241 (+551.35%)
Mutual labels:  javascript-framework
Modern.JS
모던 자바스크립트 라이브러리/프레임워크 × KIPFA(한국인터넷전문가협회)
Stars: ✭ 16 (-56.76%)
Mutual labels:  javascript-framework
Covidview
A complete COVID-19 tracker cum dashboard website made by me.
Stars: ✭ 24 (-35.14%)
Mutual labels:  javascript-framework
Enact
An app development framework built atop React that’s easy to use, performant and customizable.
Stars: ✭ 178 (+381.08%)
Mutual labels:  javascript-framework
picoCSS
picoCSS - really small JavaScript Framework
Stars: ✭ 62 (+67.57%)
Mutual labels:  javascript-framework
madosel
Modasel is a family of responsive front-end frameworks that make it easy to design beautiful responsive websites, apps that look amazing on any device. Madosel is semantic, readable, flexible, and completely customizable.
Stars: ✭ 39 (+5.41%)
Mutual labels:  javascript-framework
Mixed-Reality-JS
A simple framework for building Hololens applications with Javascript and ThreeJS. Based on HoloJS.
Stars: ✭ 54 (+45.95%)
Mutual labels:  javascript-framework
Yalla
YallaJS, ES6 Templating Engine.
Stars: ✭ 253 (+583.78%)
Mutual labels:  javascript-framework
fyu
Do your users take your website for granted? Do want to make them using your website living hell? Look no further, F.Y.U. is here!
Stars: ✭ 53 (+43.24%)
Mutual labels:  javascript-framework
continuum-engine
A Javascript engine to power incremental and idle games
Stars: ✭ 45 (+21.62%)
Mutual labels:  javascript-framework
Metal.js
Build UI components in a solid, flexible way
Stars: ✭ 227 (+513.51%)
Mutual labels:  javascript-framework
smart-custom-element
Smart a lightweight web component library that provides capabilities for web components, such as data binding, using es6 native class inheritance. This library is focused for providing the developer the ability to write robust and native web components without the need of dependencies and an overhead of a framework.
Stars: ✭ 17 (-54.05%)
Mutual labels:  javascript-framework
Server Components
🔧 A simple, lightweight tool for composable HTML rendering in Node.js, based on web components.
Stars: ✭ 212 (+472.97%)
Mutual labels:  javascript-framework
nautil
Nautil.js is a javascript framework for building cross-platform business system applications based on React.
Stars: ✭ 67 (+81.08%)
Mutual labels:  javascript-framework
Mage
Mage is a 3D Game Engine, built on top of THREE.js. It features Unity-like scripting, AMMO.js powered physics workers, an Infernojs powered UI and a clean API. Under (very) active development.
Stars: ✭ 76 (+105.41%)
Mutual labels:  javascript-framework
writing-a-javascript-framework
Knowledge about creating a javascript framework
Stars: ✭ 74 (+100%)
Mutual labels:  javascript-framework
whatsapp-clone-react
Build a WhatsApp Clone with React JS and FireBase.
Stars: ✭ 38 (+2.7%)
Mutual labels:  javascript-framework

RobotlegsJS

Join the chat at https://gitter.im/GoodgameStudios/RobotlegsJS Build Status Code Climate Test Coverage npm version Greenkeeper badge

NPM NPM

Robotlegs is a architecture-based IoC framework for JavaScript/TypeScript. This version is a direct port from the ActionScript 3.0 codebase. See the motivation behind it.

Right now, this framework only works together with pixi.js v4.

Features

  • Dependency injection (through InversifyJS)
  • Command management
  • View management

Installation

You can get the latest release and the type definitions using npm:

npm install robotlegs reflect-metadata --save

RobotlegsJS requires TypeScript 2.0 and the experimentalDecorators, emitDecoratorMetadata, types and lib compilation options in your tsconfig.json file:

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["es6", "dom"],
        "module": "commonjs",
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    }
}

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.

let renderer = PIXI.autoDetectRenderer(800, 600, {});
let context = new Context()
        .install(MVCSBundle)
        .configure(MyAppConfig, SomeOtherConfig)
        .configure(new ContextView((<any>this.renderer).plugins.interaction));

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.

See Framework docs.

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.

let 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.

See ContextView docs.

Application & Module Configuration

A simple application configuration file might look something like this:

import {
   IConfig,
   IInjector,
   IMediatorMap,
   IEventCommandMap,
   ContextView,
   inject
} from "robotlegs";

public class MyAppConfig implements IConfig
{

    @inject(IInjector)
    injector: IInjector;

    @inject(IMediatorMap)
    mediatorMap: IMediatorMap;

    @inject(IEventCommandMap)
    commandMap: IEventCommandMap;

    @inject(IContextView)
    contextView: IEventCommandMap;

    public function configure(): void
    {
        // Map UserModel as a context enforced singleton
        this.injector.bind(UserModel).toSelf().inSingletonScope();

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

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

        // The "view" property is a DisplayObjectContainer reference.
        this.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.

See Framework documentation

An Example Mediator

The mediator we mapped above might look like this:

import { inject, IEventMap, IEventDispatcher, Mediator } from "robotlegs";
import { UserProfileView } from "./UserProfileView";

public class UserProfileMediator extends Mediator<UserProfileView>
{
    public function initialize():void
    {
        // Redispatch an event from the view to the framework
        this.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:

import { Command, inject } fro "robotlegs";

public class UserSignInCommand extends Command
{
    @inject(UserEvent)
    event: UserEvent;

    @inject(UserModel)
    model: UserModel;

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

The event that triggered this command is available for Injection.

See EventCommandMap docs.

Motivation

There is plenty of frameworks and patterns out there that helps you to write DOM-based applications. There is no scalable solution yet to architecture a canvas-based application though.

Robotlegs has proven itself of being a mature solution from the ActionScript community for interactive experiences.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].