tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/146-proxy-reference-in-the-viewRobotlegs: Discussion 2015-10-19T23:47:51Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/16030732010-05-04T21:39:06Z2010-05-04T21:39:06ZProxy Reference in the View?<div><p>If you want to go that route put the reference to the
Model/Proxy in your mediator, not the view. I always use VOs, but
it makes sense on a smaller app or early in development to go the
convenient route.</p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/16030732010-05-04T21:57:24Z2015-10-19T23:47:51ZProxy Reference in the View?<div><p>Hi Joel,</p>
<p>Yes that what I suspected, and I often do something like the
following:</p>
<p>class MyMediator exends Mediator<br>
{ [Inject] public var view : MyView;<br>
[Inject] public var proxy : MyProxy;</p>
<pre>
<code>override public function onRegister()
{
view.model = proxy.model;
}</code>
</pre>
<p>}</p>
<p>and then have the view bind to bindables in the "model"</p>
<p>However, suppose that 'model' in proxy doesnt always have an
instance. Suppose that sometimes it gets set to null then sometimes
it gets given an instance. This method wouldnt work then as the
instance set in onRegister is no longer valid.</p>
<p>I suppose you coul add a ChangeWatcher in the mediator to do
something like the following:</p>
<p>class MyMediator exends Mediator<br>
{ [Inject] public var view : MyView;<br>
[Inject] public var proxy : MyProxy;</p>
<pre>
<code>override public function onRegister()
{
BindingUtils.bindProperty(view,"model",proxy,"model");
}</code>
</pre>
<p>}</p>
<p>But I dont really having string property references in my code,
another reason why I love signals over events and RL over Mate
;)</p>
<p>Mike</p></div>mike.canntag:robotlegs.tenderapp.com,2009-10-18:Comment/16030732010-05-04T22:24:39Z2010-05-04T22:24:39ZProxy Reference in the View?<div><p>Just be sure to actually ref the ChangeWatcher so you can
unWatch in onRemove() :></p>
<p>My general rule is to bind to values, not objects. Values can
and do include value objects, but VO are just a collection of
properties so that is OK. What you describe is definitely a way to
have a presentation model injected into your view, which is
interesting.</p></div>Joel Hooks