tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/570-signals-problemRobotlegs: Discussion 2012-05-16T09:51:53Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-15T09:34:36Z2012-05-15T09:34:36ZSignals problem<div><p>i think you want to map a singleton instance of StageResized
before you map the StageResized signal to the StageResizeCommand,
and then get that signal to dispatch in your event handler.
StageResized should extend Signal with a StageVO argument.</p>
<p>class StageResized extends Signal<br>
{ function StageResized() {</p>
<pre>
<code> super( StageVO );</code>
</pre>
<p>} }</p>
<p>then in your context:<br>
public var resizeSignal : StageResized = new StageResized();<br>
injector.mapValue( StageResized, resizeSignal );</p></div>matttag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-15T10:15:49Z2012-05-15T10:26:02ZSignals problem<div><p>hi matt,</p>
<p>i updated my Signal library and did what you advised. however my
StageResizeCommand is not called :s</p>
<p><code>contextView.stage.addEventListener(Event.RESIZE,
stageResized);</code></p>
<p>`private function stageResized(e:Event):void{</p>
<pre>
<code> var stageVO:StageVO = new StageVO();
stageVO.width = contextView.stage.stageWidth;
stageVO.height = contextView.stage.stageHeight;
resizeSignal.dispatch(stageVO);
}`</code>
</pre>
<p>thanks,<br>
carlos</p></div>kakarlustag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-15T10:38:39Z2012-05-15T10:38:40ZSignals problem<div><p>heres my SignalCommand class</p>
<p>`package lib.controller.commands {</p>
<pre>
<code>import org.robotlegs.mvcs.SignalCommand;
import lib.model.vos.StageVO;
import flash.external.ExternalInterface;
public class StageResizeCommand extends SignalCommand{
[Inject]
public var stageVO:StageVO;
override public function execute():void{
ExternalInterface.call("console.log('wakeke stage resize wohoo!')");
}
}</code>
</pre>
<p>}`</p></div>kakarlustag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-15T13:54:49Z2012-05-15T13:56:37ZSignals problem<div><p>Hi Carlos,</p>
<p>It seems you want to dispatch your signal from within your
context, right?</p>
<p>-Mappings: //injector.mapSingleton(StageVO);</p>
<p>injector.mapSingleton(StageResized);</p>
<p>signalCommandMap.mapSignalClass(StageResized,
StageResizeCommand);</p>
<p>-In your handler method:</p>
<p>var resizeSignal: StageResized;<br>
var stageVO:StageVO = new StageVO();<br>
stageVO.width = contextView.stage.stageWidth;<br>
stageVO.height = contextView.stage.stageHeight;</p>
<p>
<strong>resizeSignal=injector.getInstance(StageResized);</strong></p>
<p>resizeSignal.dispatch(StageVO);</p>
<p>This should actually work.<br>
Try it and let us know whether it solved your problem or not.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-16T02:42:06Z2012-05-16T02:42:06ZSignals problem<div><p>hi ondina it worked :D thanks very much to matt & u.</p></div>kakarlustag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-16T04:30:01Z2012-05-16T04:30:01ZSignals problem<div><p>next problem is how am i going to send that signal from my
StageResizeCommand -> ComponentModel -> ComponentMediator
-> ComponentView</p>
<p>if im going to use the eventMap.mapListener in my mediator, its
defeating the purpose of me using signals right?</p>
<p>what should i do in my model to make a signal connection to the
mediator and then to the view.</p>
<p>thanks,<br>
carlos</p></div>kakarlustag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-16T08:07:40Z2012-05-16T08:07:40ZSignals problem<div><p>Hey Carlos,</p>
<p>You’re welcome, and I’m glad our combined efforts
have led to a solution :)</p>
<blockquote>
<p>if im going to use the eventMap.mapListener in my mediator, its
defeating the purpose of me using signals right?</p>
</blockquote>
<p>Well, what can I say? Of course you can use both, events
<strong>and</strong> signals. You’ll have to decide about
that, depending on the size and structure of your application. You
can trigger a command by dispatching a signal, and another command
by dispatching an event, or trigger a command through signals and
let the model dispatch an event, as you said, but it would be kind
of confusing, especially in a large application. It’s all a
matter of personal preference. There are many discussions about
that on this forum. One of them:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/problems/509-large-number-of-signalscommandsmediatorsviews">
http://knowledge.robotlegs.org/discussions/problems/509-large-numbe...</a></p>
<blockquote>
<p>what should i do in my model to make a signal connection to the
mediator and then to the view.</p>
</blockquote>
<p>You would map your signal in your Context:</p>
<p>injector.mapSingleton(StageVO);</p>
<p>injector.mapSingleton(StageResizeSignal);</p>
<p>You would inject your signal in your model:</p>
<p>[Inject] public var resizeSignal: StageResizeSignal;</p>
<p>and when needed you’d dispatch it:<br>
resizeSignal.dispatch(stageVO);</p>
<p>In your Mediator:<br>
[Inject] public var resizeSignal: StageResizeSignal;</p>
<p>override public function onRegister():void<br>
{</p>
<p>resizeSignal.add(onStageResized);<br>
…</p>
<p>protected function onStageResized (value: StageVO):void<br>
{</p>
<p>view.doSomethingWith(value);<br>
}</p>
<p>Does this answer your question?</p>
<p>Have you looked at examples using signals already?<br>
Here is a list of demos, examples, tutorials:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/resources/33-links-to-robotlegs-resources-examples-tutorials">
http://knowledge.robotlegs.org/discussions/resources/33-links-to-ro...</a><br>
Just in case you didn’t know about this ;)</p>
<p>If you search for signals you’ll find lots of entries.<br>
Cheers,<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-16T09:28:57Z2012-05-16T09:28:57ZSignals problem<div><p>ahh so thats how a signal works (didnt do my research). i got
really confused what .add() was for, now i know its for adding a
listener to the signal.</p>
<p>really helped me there cheers ondina.</p>
<p>thanks,<br>
carlos</p></div>kakarlustag:robotlegs.tenderapp.com,2009-10-18:Comment/159993102012-05-16T09:51:51Z2012-05-16T09:51:51ZSignals problem<div><p>Cool! Have fun with signals :)<br>
I'm going to mark this issue as resolved. You can reopen the
discussion at any time, if need be.<br>
Ondina</p></div>Ondina D.F.