ViewProcessorMap vs ViewMap

saqsun's Avatar

saqsun

15 Jan, 2014 08:33 AM

Hi guys,
Thanks for such a great framework!
Guys can you explain why we need ViewProcessorMap if we already have ViewMap. What the difference?

  1. Support Staff 1 Posted by Ondina D.F. on 15 Jan, 2014 12:02 PM

    Ondina D.F.'s Avatar

    Hello,

    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.

    https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...

    Are you, by any chance, using a Starling extension for rl2? If so, are you asking about the ViewMap used by those extensions?

    If you need help with the ViewProcessorMap, please provide more info about your specific use case :)

    Ondina

  2. 2 Posted by saqsun on 15 Jan, 2014 04:53 PM

    saqsun's Avatar

    Sorry for confused question.
    My question is about MediatorMap and ViewProcessorMap. I do not understand why we need "viewProcessor" if we already have "mediator"?

  3. Support Staff 3 Posted by Ondina D.F. on 16 Jan, 2014 11:01 AM

    Ondina D.F.'s Avatar

    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:

    https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...
    https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practice...

    I apologize, if you knew all this already:)

    Simply put, the MediatorMapExtension is specialized in creating Mediators.
    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.

    On the other hand, the ViewProcessorMap is specialized in "processing" Views, where "processing" means that a View mapped with the viewProcessorMap will be injected 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.

    From the docs: " A difference between the mediatorMap and the viewProcessorMap: in the mediatorMap, mediators can be injected into hooks. In the viewProcessorMap they aren't mapped for injection at all."

    If you don't need Mediators, because you're using other patterns, use the viewProcessorMap.

    You can use the mediatorMap and the viewProcessorMap for the same View, if you really wanted or needed to. For example:

    injector.map(ISomeObject).toSingleton(SomeObject);
    mediatorMap.map(SomeView).toMediator(SomeMediator);
    viewProcessorMap.map(SomeView).toInjection();
    

    or only the viewProcessorMap:

    injector.map(ISomeObject).toSingleton(SomeObject);
    viewProcessorMap.map(SomeView).toProcess(new MediatorCreator(SomeMediator));
    viewProcessorMap.map(SomeView).toInjection();
    

    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:

    [Inject]
    public var someObjet: ISomeObject;
    

    If you don't need a Mediator for SomeView, just some dependency injected into it:

    injector.map(ISomeObject).toSingleton(SomeObject);
    viewProcessorMap.map(SomeView).toInjection();
    

    Did I answer your question?

    Ondina

  4. 4 Posted by saqsun on 16 Jan, 2014 05:31 PM

    saqsun's Avatar

    Now I got it :)
    Thanks a lot for detailed answer!

  5. Support Staff 5 Posted by Ondina D.F. on 17 Jan, 2014 09:57 AM

    Ondina D.F.'s Avatar

    Cool! You're welcome:)

  6. Ondina D.F. closed this discussion on 17 Jan, 2014 09:57 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac