injecting model into mediator
I don't understand this line :
[Inject]
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.
V.
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Stray on 31 May, 2012 11:24 AM
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.
Stray
3 Posted by vishwas.gagrani on 31 May, 2012 11:52 AM
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].
V.
4 Posted by krasimir on 31 May, 2012 11:58 AM
Hello,
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).
5 Posted by vishwas.gagrani on 31 May, 2012 12:59 PM
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 ?
V.
6 Posted by Stray on 31 May, 2012 01:02 PM
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.
hth,
Stray
7 Posted by vishwas.gagrani on 31 May, 2012 04:35 PM
k, thnx. I will get one.
8 Posted by wagster on 31 May, 2012 09:50 PM
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.
vishwas.gagrani closed this discussion on 09 Jun, 2012 11:16 AM.