tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/2209-mediator-maps-value-twiceRobotlegs: Discussion 2013-04-12T09:04:14Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-03T18:34:58Z2013-04-03T18:34:59ZMediator maps value twice<div><p>Hm...I've found the following line of code in
StarlingMediatorMap.as:</p>
<p><code>setTimeout(removeMediatorLater, 500, null);</code></p>
<p><a href=
"https://github.com/s9tpepper/robotlegs-starling-plugin/blob/master/src/org/robotlegs/base/StarlingMediatorMap.as#L317">
https://github.com/s9tpepper/robotlegs-starling-plugin/blob/master/...</a></p>
<p>Because of this delay in 500 ms, onRegister() is called for the
second time before onRemoved() was called for the first time.</p>
<p>Did anyone face this problem?</p></div>anton.yakovenko1991tag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-04T10:41:56Z2013-04-04T10:41:56ZMediator maps value twice<div><p>Hi Anton,</p>
<p>Good catch.<br>
You could open an issue here: <a href=
"https://github.com/s9tpepper/robotlegs-starling-plugin/issues">https://github.com/s9tpepper/robotlegs-starling-plugin/issues</a>,<br>
but who knows whether the starling plugin for robotlegs 1 will be
updated….</p>
<p>The extension for robotlegs 2 works fine.<br>
<a href=
"https://github.com/Vj3k0/robotlegs-extensions-starling">https://github.com/Vj3k0/robotlegs-extensions-starling</a><br>
<a href=
"https://github.com/Vj3k0/robotlegs-extensions-SARS">https://github.com/Vj3k0/robotlegs-extensions-SARS</a></p>
<p>forked from:<br>
<a href=
"https://github.com/alebianco/robotlegs-extensions-starling">https://github.com/alebianco/robotlegs-extensions-starling</a></p>
<p>with example:<br>
<a href=
"https://github.com/alebianco/StarlingExtension-example">https://github.com/alebianco/StarlingExtension-example</a></p>
<p>Note: I don’t know if the above mentioned rl2 extensions
work with the latest build of rl2.</p>
<p>Many things are better, and easier to do in rl2. I recommend
using it :)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-09T08:17:06Z2013-04-09T08:17:08ZMediator maps value twice<div><p>Thanks a lot!</p>
<p>I think I'll check RL2.<br>
Could you tell me, are there major differences between RL1 and
RL2?</p>
<p>Thanks,<br>
Anton.</p></div>anton.yakovenko1991tag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-09T16:23:53Z2013-04-09T16:23:53ZMediator maps value twice<div><p>Hey Anton,</p>
<blockquote>
<p>Could you tell me, are there major differences between RL1 and
RL2?</p>
</blockquote>
<p>There are differences between the 2 versions. I won’t be
able to mention all of them in much detail, because I would end up
writing a tutorial, and I’m afraid I wouldn’t be very
good at it and it would take me too long.<br>
I’ll try to do my best though. I’ll explain just a few
terms to get you started.<br>
Some of the definitions used bellow are extracted from the docs on
github, some others are my own interpretations..<br>
The main key words: extension, bundle, configuration, installation,
contextView, context</p>
<p>Let’s start here:<br>
<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a><br>
Read the READMEs, too!</p>
<p>You can see the new strucutre:</p>
<p>-extensions [<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions">https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]</p>
<p>-bundles [<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/bundles">https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]</p>
<p>-framework [<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/framework">https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]</p>
<p>An <strong>extension</strong> integrates a single utility or
library into a Robotlegs context.</p>
<p>A <strong>bundle</strong> bundles up a selection of extensions
and configurations into a single drop-in package.</p>
<p>A <strong>configuration</strong> is a custom class, where you
map your mediators, commands, or whatever you need to make your app
work as expected.</p>
<p>The <strong>Context View</strong> represents the root
DisplayObjectContainer for a Context</p>
<p>A <strong>context</strong> is a scope. It is core to any
application or module built using Robotlegs.<br>
[<a href=
"https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/framework/readme-context.md">https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a>]</p>
<p>The Context adds framework features by composition –
<strong>installs</strong> extensions.<br>
For example, if an rl2 app uses Mediators, the needed extension
is… you guessed it… MediatorMapExtension. If
you’ll never use Commands, then the CommandCenterExtension
doesn’t need to be installed into your Context.<br>
Very flexible, isn’t it?</p>
<p>There are a few built-in extensions. For an MVCS app you’d
need the extensions provided by the <strong>MVCSBundle</strong>.[
<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/bundles/mvcs">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]</p>
<p>For special needs, developers can build their own extensions or
use the ones built by others (for example <a href=
"https://github.com/Vj3k0/robotlegs-extensions-SARS">https://github.com/Vj3k0/robotlegs-extensions-SARS</a>
- An extension to enable integration of Starling, Away3D 4.0,
Robotlegs and Signals.)</p>
<p>Now, you might ask: should I care about those extensions and
bundles and all framework classes?<br>
Yes and no.</p>
<p>Knowing which extension does what might help you decide what to
use for a certain use case.<br>
Say, you wanted to have Modules in your app. The
ModularityExtension is already included in the MVCSBundle, but if
you wanted your modules to communicate with each other, you’d
need the ScopedEventDispatcherExtension, too.</p>
<p>What’s different from rl1? All of the above and...</p>
<ul>
<li>You don’t need to extend the Context class anymore. To
create a context simply instantiate a new Context and provide
<strong>some configuration</strong>:</li>
</ul>
<pre>
<code>_contextView = new ContextView(this); ;// DisplayObjectContainer
_context = new Context()
.install(MVCSBundle)
.configure(MediatorsConfig, ModelsConfig, contextView);</code>
</pre>
<pre>
<code>class MediatorsConfig implements IConfig
{
[Inject]
public var mediatorMap:IMediatorMap;
public function configure():void
{
mediatorMap.map(SomeView)
.toMediator(SomeMediator);
}
}</code>
</pre>
<ul>
<li>
<p>You don’t need to split up your bootstrapping process into
several commands anymore. You can organize your mappings by using
custom config files, say MediatorsConfig, CommandsConfig,
ModelsConfig, etc</p>
</li>
<li>
<p>an rl2 <strong>Mediator overrides initialize()</strong> instead
of rl1’s onRegister, and <strong>destroy()</strong> instead
of onRemove</p>
</li>
<li>
<p><strong>Commands don’t need to override execute()</strong>
anymore and also don’t need to extend Command. Any class with
a public execute method can be used.</p>
</li>
<li>
<p>there is <strong>no Actor</strong> in rl2 anymore. You can use
any class for your Models and Services and if you want them to be
able to dispatch events on the shared event dispatcher, you inject
the dispatcher like this:</p>
</li>
</ul>
<pre>
<code>[Inject]
public var dispatcher:IEventDispatcher;</code>
</pre>
<ul>
<li><strong>swiftsuspenders v.2</strong> ’s new syntax. Here,
just a few common mappings:</li>
</ul>
<pre>
<code>rl1: mediatorMap.mapView(SomeView, SomeMediator);
rl2: mediatorMap.map(SomeView).toMediator(SomeMediator);
rl1: commandMap.mapEvent(SomeEvent.SOME_TYPE, SomeCommand, SomeEvent, true);
rl2: commandMap.map(SomeEvent. SOME_TYPE).toCommand(SomeCommand);
rl1: injector.mapSingleton(SomeModel);
rl2: injector.map(SomeModel).asSingleton();</code>
</pre>
<p>Easy, right?</p>
<p>For starters, keep in mind that the minimum you’d need to
build an rl2 app is a ContextView, a Context, the MVCSBundle and
your own configuration file(s).</p>
<p>Other -very cool- new features (you don’t need to care
about them right now though): guards, hooks, lifecycle,
ViewProcessorMapExtension</p>
<p>I suggest looking at examples [<a href=
"http://knowledge.robotlegs.org/discussions/examples/20-links-to-robotlegs-v2-articles-examples-demos-utilities-and-tutorials">http://knowledge.robotlegs.org/discussions/examples/20-links-to-rob...</a>],
even if not all of them have been updated to work with the latest
rl2 build. Also, go through the entire documentation on github,
just to get familiar with the new terminology and classes. Try out
a simple example and come back to our forum to ask specific
questions, if you get stuck. We’ll do our best to help you
become a happy rl2 user ;)</p>
<p>I hope my incomplete mini-guide will help you, at least a little
bit, to get started.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-10T14:26:19Z2013-04-10T14:27:13ZMediator maps value twice<div><p>Thanks, I could not get better answer!)</p>
<p>By the way, I have found this fork of robotlegs starling
pluin:</p>
<p><a href=
"https://github.com/edmundito/robotlegs-starling-plugin">https://github.com/edmundito/robotlegs-starling-plugin</a></p>
<p>Looks like it works well without warnings.</p>
<p><code>Robotlegs Support Rocks! :)</code></p></div>anton.yakovenko1991tag:robotlegs.tenderapp.com,2009-10-18:Comment/262079282013-04-12T08:59:37Z2013-04-12T08:59:37ZMediator maps value twice<div><p>You're welcome and thanks for the kind words!<br>
Closing this thread for now.</p></div>Ondina D.F.