tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/611-why-a-use-signal-for-view-to-mediator-communicationRobotlegs: Discussion 2018-10-18T16:35:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/87653562011-07-21T10:23:38Z2011-07-21T10:23:38ZWhy a use signal for view to mediator communication?<div><p>My view -> mediator signals are just vanilla signals that are
properties of the view. The fact that the mediator-view
relationship is 1:1 means you don't need to further identify it
with a class for injection - just expose it with a getter.</p>
<p>So - your first signal can be simply</p>
<p>new Signal(somePropTypes...)</p>
<p>Does that make sense?</p>
<p>Definitely don't inject the signal into the view.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/87653562011-07-21T10:40:20Z2011-07-21T10:40:20ZWhy a use signal for view to mediator communication?<div><p>I think so. So if I include the signals path I'd create the
signal in my declerations tag with</p>
<p><signals:Signal id="playlistSelected" /></p>
<p>And then from my dropdown list dispatch it with</p>
<p><s:DropDownList id="playlistDropDown"
change="{playlistSelected.dispatch(playlistDropDown.selectedIndex)}"
/></p>
<p>??</p>
<p>This works and seems cleaner straight away. But when you say my
signal can simply be new Signal(somePropTypes...), are you
suggesting I can create the signal at the time of dispatching it
rather than in two steps?</p></div>eddie.amphletttag:robotlegs.tenderapp.com,2009-10-18:Comment/87653562011-07-21T10:55:24Z2011-07-21T10:55:24ZWhy a use signal for view to mediator communication?<div><p>Hi Eddie -</p>
<p>I was suggesting you create the signal as a property - as you
have here, except that you'll need to declare the return type so
that you can send that selectedIndex property in the dispatch. I'm
afraid I'm a pure-as3-only girl so I don't know the mxml equivalent
of new Signal(uint)... but I'm sure you do.</p>
<p>Stray</p>
<p>On 21 Jul 2011, at 11:39, eddie.amphlett wrote</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/87653562011-07-21T11:03:50Z2011-07-21T11:03:50ZWhy a use signal for view to mediator communication?<div><p>Cool. It all seems to be working fine and is looking lots
tidier.</p>
<p>Thanks very much,<br>
Ed</p></div>eddie.amphletttag:robotlegs.tenderapp.com,2009-10-18:Comment/87653562011-07-21T12:27:30Z2011-07-21T12:27:30ZWhy a use signal for view to mediator communication?<div><p>Hi Eddie.</p>
<p>Your second attempt is ok. You just did what Stray meant. In
declaration field you introduced a property (after compilation it's
converted to getter/setter. She also suggested you to introduce
value classes - type of dispatched values. You can also do it in
MXML like this:</p>
<pre>
<code><signals:Signal id="playlistSelected">{int}</signals:Signal></code>
</pre>
<p>All MXML notation for Signals are stored <a href=
"https://github.com/robertpenner/as3-signals/blob/master/tests/org/osflash/signals/support/SpriteWithSignals.mxml">
here</a>.</p>
<p>And just one tip from me. If your view dispatches the same type
of values as mediator injected signals you can assign injected
signals in Mediator to your view instance. It should be done in
onRegister. Then you don't need to listen and dispatch in Mediator.
But you should remember that the instance of signal previously
created by the view will disappear.</p>
<p>I hope it's clear :)</p>
<p>Mike</p></div>Michal Wroblewski