tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/694-can-i-access-a-model-from-a-viewRobotlegs: Discussion 2018-10-18T16:35:33Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T09:30:19Z2011-10-13T09:30:20ZCan I access a Model from a View?<div><p>You could inject the model in your view Mediator</p>
<pre>
<code>[Inject]
public var drawingModel:YourModel</code>
</pre>
<p>but you could also dispatch an Event with coordiantes as an
argument from your Model each time a new shape has been added to
your Model. Make your view Mediator listen to that event.</p></div>Pierre Laveklinttag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T09:57:26Z2011-10-13T09:57:27ZCan I access a Model from a View?<div><p>Or you could pass the reference from the mediator to the view,
and access the model directly from the view (but Pierre's
suggestion is the more "correct" one).</p></div>Pedertag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T10:07:43Z2011-10-13T10:07:43ZCan I access a Model from a View?<div><p>Thanks for the replies! What about adding a ViewController and
inject the Model into it to handles the logic?</p></div>Gert-Jan van der Weltag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T10:26:18Z2011-10-13T10:26:18ZCan I access a Model from a View?<div><p>Yep, it's a good idea to add the model calls in a command class
and hook an event to fire the command. Update the model in the
command and dispatch a change of state event from the model which
you can listen to from any other application tier - mvc pattern at
it's best. :)</p></div>Pedertag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T10:30:15Z2011-10-13T10:30:15ZCan I access a Model from a View?<div><p>Something to throw into the equation: <a href=
"http://www.1ndivisible.com/?p=9">http://www.1ndivisible.com/?p=9</a>
as a possible option....</p></div>simontag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T11:06:10Z2011-10-13T11:06:10ZCan I access a Model from a View?<div><p>@simon correct me if i'm wrong, but did you do this to have
Presenters for your Views so you could have the logic in the
Presenter instead of the View itself?</p></div>Gert-Jan van der Weltag:robotlegs.tenderapp.com,2009-10-18:Comment/105950242011-10-13T12:06:48Z2011-10-13T12:06:48ZCan I access a Model from a View?<div><p>Yes following the train of thought of PM but not the exact
implementation. I<br>
thought I would just suggest it to mull over :)</p></div>simon