Injections in custom classes.

mur4ik's Avatar

mur4ik

25 Jul, 2013 12:10 PM

Hi.

How to staisfy injections in some class?
For example I have item renderer and I would like inject a service or model or shared event dispatcher and so on into it.
I know that I can make Mediators for my Item renderers, but may be in my case injecting directly could be a better solution.

  1. Support Staff 1 Posted by Ondina D.F. on 25 Jul, 2013 01:17 PM

    Ondina D.F.'s Avatar

    Hi,

    I wouldn't inject anything into ItemRenderers and I also wouldn't mediate them. Instead, I'd mediate the View component that uses them. I like the ItemRenderers to be encapsulated and independent from any framework. I also wouldn't inject Services into Views. Injecting Models into views is a debatable practice as well, when using the MVCS pattern.
    Just my opinion:)

    Injecting into Views can be done by using the viewProcessorMap.

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

    injector.map(SomeModel).asSingleton();
    viewProcessorMap.map(SomeView).toInjection();

    Ondina

  2. 2 Posted by mur4ik on 25 Jul, 2013 08:52 PM

    mur4ik's Avatar

    Thanks.

  3. mur4ik closed this discussion on 25 Jul, 2013 08:53 PM.

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