tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/9224-viewprocessormap-vs-viewmapRobotlegs: Discussion 2014-01-17T13:16:22Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-15T08:33:46Z2014-01-15T08:33:46ZViewProcessorMap vs ViewMap <div><p>Hi guys,<br>
Thanks for such a great framework!<br>
Guys can you explain why we need ViewProcessorMap if we already
have ViewMap. What the difference?</p></div>saqsuntag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-15T12:02:25Z2014-01-15T12:02:25ZViewProcessorMap vs ViewMap <div><p>Hello,</p>
<p>There is no ViewMap in Robotlegs v.2. The ViewMap from Robotlegs
v. 1 became ViewProcessorMap in Robotlegs 2. The ViewProcessorMap
is more complex and powerful than the rl1's ViewMap.</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/extensions/viewProcessorMap/readme.md">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
<p>Are you, by any chance, using a Starling extension for rl2? If
so, are you asking about the ViewMap used by those extensions?</p>
<p>If you need help with the ViewProcessorMap, please provide more
info about your specific use case :)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-15T16:53:52Z2014-01-15T16:53:52ZViewProcessorMap vs ViewMap <div><p>Sorry for confused question.<br>
My question is about MediatorMap and ViewProcessorMap. I do not
understand why we need "viewProcessor" if we already have
"mediator"?</p></div>saqsuntag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-16T11:01:18Z2014-01-16T11:01:18ZViewProcessorMap vs ViewMap <div><p>I don't know how much you already know about the MVCS
meta-design pattern and the roles of Mediators. The Best Practices
wiki was written for robotlegs v.1, but the principles are still
the same with robotlegs 2:</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices#mvcs-reference-implementation">
https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...</a><br>
<a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices#wiki-mediators">
https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...</a></p>
<p>I apologize, if you knew all this already:)</p>
<p>Simply put, the MediatorMapExtension is specialized in creating
Mediators.<br>
If you need Mediators for your Views, you use the MediatorMap, to
map Views to Mediators. A Mediator will be created automatically,
the moment the View to which it has been mapped is added to the
stage. You can also mediate views manually, if you want to.</p>
<p>On the other hand, the ViewProcessorMap is specialized in
"processing" Views, where "processing" means that a View mapped
with the viewProcessorMap will be <strong>injected</strong> with
whatever dependencies it needs, the moment it is landing on the
stage. In addition to that, it can also create a Mediator for the
mapped View.</p>
<p>From the docs: " A difference between the mediatorMap and the
viewProcessorMap: <strong>in the mediatorMap, mediators can be
injected into hooks</strong>. In the viewProcessorMap they aren't
mapped for injection at all."</p>
<p>If you don't need Mediators, because you're using other
patterns, use the viewProcessorMap.</p>
<p>You can use the mediatorMap <strong>and</strong> the
viewProcessorMap for the same View, if you really wanted or needed
to. For example:</p>
<pre>
<code>injector.map(ISomeObject).toSingleton(SomeObject);
mediatorMap.map(SomeView).toMediator(SomeMediator);
viewProcessorMap.map(SomeView).toInjection();</code>
</pre>
<p>or only the viewProcessorMap:</p>
<pre>
<code>injector.map(ISomeObject).toSingleton(SomeObject);
viewProcessorMap.map(SomeView).toProcess(new MediatorCreator(SomeMediator));
viewProcessorMap.map(SomeView).toInjection();</code>
</pre>
<p>When SomeView is added to the stage, SomeObject will be injected
into SomeView and SomeMediator will be created. Of course, you'll
have to add this to SomeView:</p>
<pre>
<code>[Inject]
public var someObjet: ISomeObject;</code>
</pre>
<p>If you don't need a Mediator for SomeView, just some dependency
injected into it:</p>
<pre>
<code>injector.map(ISomeObject).toSingleton(SomeObject);
viewProcessorMap.map(SomeView).toInjection();</code>
</pre>
<p>Did I answer your question?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-16T17:31:56Z2014-01-16T17:31:56ZViewProcessorMap vs ViewMap <div><p>Now I got it :)<br>
Thanks a lot for detailed answer!</p></div>saqsuntag:robotlegs.tenderapp.com,2009-10-18:Comment/311252362014-01-17T09:57:20Z2014-01-17T09:57:20ZViewProcessorMap vs ViewMap <div><p>Cool! You're welcome:)</p></div>Ondina D.F.