access Injected Model from Mediator

JeffW.'s Avatar


21 Aug, 2011 07:05 AM


is it okay to simply access a Model from a Mediator, like


trace(model.myGetter); when you have injected that Mediator, like

public var  model:Model

Or does this somehow restrict the concept of looose coupling and should I always do this through an event/command?


  1. Support Staff 1 Posted by Ondina D.F. on 22 Aug, 2011 08:07 AM

    Ondina D.F.'s Avatar

    Hi Jeff:)
    Your question: is it okay to simply access a Model from a Mediator?

    In short there are 3 answers to this question:
    1. yes
    2. definitely no
    3. it depends


    If you search the discussions for „model into mediator“ or “model in mediator” you’ll find lots and lots of posts about this controversial topic. Read as much as you can about the topic to form your own opinion.

    I think the confusion about this matter stems also from the fact that in many “official” and less official examples models have been injected into mediators.
    Also people coming from pureMVC were used to accessing a Proxy in their Mediators, which wasn’t considered to be a bad practice.

    Conclusion: to play it safe, follow the recommended practice of not injecting models into mediators, at least until you feel more comfortable with the framework.


  2. 2 Posted by Maciek on 30 Aug, 2011 09:32 PM

    Maciek's Avatar

    A bit late to the party, but another thing you could consider doing as a compromise is have a read-only interface for a subset of the functionality of the model, and only inject that interface into the mediator. This gets you the quick-and-dirty access to the application state without compromising the sovereignty of the controller over effecting changes in application state.

  3. Ondina D.F. closed this discussion on 02 Nov, 2011 05:29 PM.

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