dynamic injection at runtime

tzamora's Avatar

tzamora

May 31, 2011 @ 03:23 AM

Hi people,

I just want to know if there exist a way to do something like these:

I have 2 named singletons in my context class

injector.mapSingleton(Yoola, 'jobs'); and injector.mapSingleton(Yoola, 'inputdata');

then some where in some class I do: [Inject (name='jobs')] public var _yoola:Yoola;

I would like to make the name string in [Inject (name='jobs')] dynamic, so I could set its value at runtime.

Is there a way to do this? if not, is there a way an Actor could retrieve the injected class in some way, maybe some thing like

var yoola:Yoola = injector.getSingleton(Yoola, 'inputdata') ?

Thanks in advance...

  1. 1 Posted by Michal Wroblews... on May 31, 2011 @ 06:42 AM

    Michal Wroblewski's Avatar

    Inject IInjector into your actor and use injector.getInstance(YourClass, "mappingName")

    BTW. Here's very useful API docs: http://robotlegs.org/api/

  2. 2 Posted by tzamora on Jun 01, 2011 @ 01:00 AM

    tzamora's Avatar

    Oh great, I searched on the best practices documents and in the internal documents, but I couldnt find something ...

    anyway, thanks a lot ...

  3. tzamora closed this discussion on Jun 01, 2011 @ 01:01 AM.

  4. Joel Hooks re-opened this discussion on Jun 01, 2011 @ 06:08 PM

  5. Support Staff 3 Posted by Joel Hooks on Jun 01, 2011 @ 06:08 PM

    Joel Hooks's Avatar

    No, the metadata is "baked" in at runtime. It would require something of
    this nature to accomplish:

    http://www.jamesward.com/2011/04/26/introducing-mixing-loom-runtime-actionscript-bytecode-modification/

    Which is well beyond the scope of RL :>

    I'd create a YoolaListModel with a method like getYoolaByName(name:String)
    that could be injected around.

    On Mon, May 30, 2011 at 10:24 PM, tzamora <
    [email blocked]> wrote:

  6. Stray closed this discussion on Jun 10, 2011 @ 03:07 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