On Vew Mediators
I wonder why not to make the framework more declarative. For
instance, instead of:
// In Mediator: [Inject] public var simpleView:SimpleView;
// In Context: mediatorMap.mapView(SimpleView, SimpleViewMediator);
// Just have this: [Inject(mediator='SimpleViewMediator')] public var simpleView:SimpleView;
And have the Context to map the view into mediator this way?
Same with the models. Instead:
injector.mapSingleton(SimpleModel);
Have it declared in the model itself:
[Inject(context='MyContextClass')]
public class SimpleModel extends Actor {
private var message: String;
...
Thanks,
Dmitry.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Shaun Smith on 08 Apr, 2010 08:12 PM
Hi Dmitry,
That's a good idea, but I see a couple of problems with that approach:
We'd still need to do the mappings somewhere in order to process the Mediator/Model (to inspect its metadata), so at very best it would just shorten the mappings:
mediatorMap.mapView(SomeMediator);It's far less flexible: the point of Inversion of Control is to remove those kinds of configuration decisions from inside our business classes and place them in a more sensible place. The SimpleModel, for example, would only be able to be used in the particular context that it has now been hard-coded into.
Classes shouldn't know (or care) how they are going to be used, it is not part of their job. The decision as to whether a class should be a singleton or not should be left up to the container (or application).
3 Posted by Nikos Katsikanis on 16 Aug, 2010 11:07 AM
I'm with Shaun
Stray closed this discussion on 13 Feb, 2011 04:27 PM.