injecting model into mediator

vishwas.gagrani's Avatar


31 May, 2012 09:54 AM

I don't understand this line :


    public var statsModel:StatsModel;

This is being used inside some view's mediator. Won't i be able to use statsModel, untill and unless i use [Inject] . What if i don't use [Inject] here ? What i have seen in other MVC designs, is that model is generally available freely within all framework actors.


  1. 1 Posted by Stray on 31 May, 2012 11:24 AM

    Stray's Avatar

    I'm assuming that when you say "model is generally available freely within all framework actors" that

    1) by 'freely available' you mean that you can access it via a static or global (neither of which is 'free' but that's a bigger story)

    2) that you have a mental concept of 'a model' as a single thing for the app, as opposed to a domain of objects holding state and logic...

    Neither of these concepts fits what Robotlegs is about - in fact, Robotlegs is designed to be the cure for both of these concepts, which are really problems in their own right, and not solutions :)

    If you do some general reading around on Robotlegs you'll find that things are done a bit differently - I'd start with the basic best practices documentation.

    To answer the question directly: if you omit the [Inject] the statsModel will be null.


  2. 2 Posted by vishwas.gagrani on 31 May, 2012 11:52 AM

    vishwas.gagrani's Avatar

    Yeah i tried to read and go through best practices, but frankly, right now, it's a bit hard for me to understand many of the terminologies there. However i have grasped some of it and still struggling...
    By freely means, I don't need to use anything like [Inject] in those framework ( talking about puremvc actually).

    btw, Which are the classes that i need to prefix with [Inject] .
    All classes ?
    Particular Classes only ? What are they ?
    Or only those classes that need [Inject].


  3. 3 Posted by krasimir on 31 May, 2012 11:58 AM

    krasimir's Avatar


    actually you should use [Inject] for those things which are mapped for injection. In your context (normally) you are saying to RobotLegs what you want to inject/use inside your classes, i.e. you are defining rules. Then by placing [Inject] in front of the variable definition you saying to RobotLegs to check your rules and to populate that variable with data (usually an instance of the mapped class).

  4. 4 Posted by vishwas.gagrani on 31 May, 2012 12:59 PM

    vishwas.gagrani's Avatar

    Is this a MUST for whatever classes (ie. not just framework actors ) i need to use inside my "xyzMediator".
    ie, any type of class instance i need to use , i MUST do this :
    1) map for injection inside context
    2) use [Inject] and then define the class

    Is their any example of class, that might not use [Inject] before it ?


  5. 5 Posted by Stray on 31 May, 2012 01:02 PM

    Stray's Avatar

    Hi Vishwas,

    I realise that I have a vested interest, but it would be worth buying the "Actionscript Developer's Guide to Robotlegs" - you can get it as an ebook from O'Reilly. It's intended to be a guide for developers at all levels, that takes you through everything you need to know to get up and running with Robotlegs properly.



  6. 6 Posted by vishwas.gagrani on 31 May, 2012 04:35 PM

    vishwas.gagrani's Avatar

    k, thnx. I will get one.

  7. 7 Posted by wagster on 31 May, 2012 09:50 PM

    wagster's Avatar

    Do. I do not have a vested interest, but it taught me all I needed to know, quickly. And I'm not super-smart either. If you can figure out PureMVC without a degree in CS, you'll be all over this in no time.

  8. vishwas.gagrani closed this discussion on 09 Jun, 2012 11:16 AM.

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

Keyboard shortcuts


? 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