Dependency injection (through InversifyJS)
RobotlegsJS-Macrobot: extends commands, adding support to async and macro commands.
Some companies using RobotlegsJS
You can get the latest release and the type definitions using NPM:
npm install @robotlegsjs/core reflect-metadata --save
Or using Yarn:
yarn add @robotlegsjs/core reflect-metadata
⚠️ Important! RobotlegsJS requires TypeScript >= 2.0 and the
libcompilation options in your
"compilerOptions":"target": "es5""lib": "es6" "dom""types": "reflect-metadata""module": "commonjs""moduleResolution": "node""experimentalDecorators": true"emitDecoratorMetadata": true
If your environment doesn't support one of these you will need to import a shim or polyfill.
reflect-metadatapolyfill should be imported only once in your entire application because the Reflect object is mean to be a global singleton. More details about this can be found here.
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.
;.installMVCSBundle.configureMyAppConfig, SomeOtherConfig.configurenew ContextViewanythis.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.
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.
Note: This does not apply to Flex MXML configuration as the ContextView is automatically determined and initialization will be automatic.
Application & Module Configuration
A simple application configuration file might look something like this:
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.
An Example Mediator
The mediator we mapped above might look like this:
The view that caused this mediator to be created is available for Injection.
An Example Command
The command we mapped above might look like this:
The event that triggered this command is available for Injection.
There are many 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.