tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/216-issue-with-signalcommandmapRobotlegs: Discussion 2018-10-18T16:35:19Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-15T17:32:48Z2010-11-15T17:32:48ZIssue with signalCommandMap<div><p>Hi Nikos,</p>
<p>basically, if the signal hasn't fired it won't yet exist as a singleton to be injected.</p>
<p>So - to inject into mediators is something like this in your context (or where you are doing mapSignalClass):</p>
<p>var applicationUserChangedSignal:ApplicationUserChanged = new ApplicationUserChanged();<br />
signalCommandMap.mapSignal(applicationUserChangedSignal, GetSelectedApplicationUserDataCommand);</p>
<p>But you might want to check some more examples.</p>
<p>I can't quite remember whether you need to map that signal as a singleton and then do get instance, or whether you just map the value as a singleton, or whether the SCM takes care of it all... but that's the gist.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-15T17:55:41Z2010-11-15T17:58:44ZIssue with signalCommandMap<div><blockquote><p>basically, if the signal hasn't fired it won't yet exist as a singleton to be injected.</p></blockquote>
<p>I don't think this is the case. The contents of <code>SignalCommandMap#mapSignalClass</code> are:<br />
</p>
<pre><code>var signal:ISignal = getSignalClassInstance( signalClass );
mapSignal( signal, commandClass, oneShot );
return signal;</code></pre>
<p><code>getSignalClassInstance</code> typically leads to <code>createSignalClassInstance</code>, which is responsible for creating and mapping signals.</p>
<p>So, the <code>mapSignalClass</code> call is <em>already</em> instantiating the appropriate signal (if necessary), and mapping it as a singleton.</p>
<p>Nikos, does your Context change the Injector instance mapped to the IInjector class? I ask because the <code>SignalCommandMap</code> generates and maps its signal-singletons using an IInjector instance obtained by calling <code>injector.getInstance(IInjector);</code> , where the first <code>injector</code> there is the SignalCommandMap's internal IInjector, which is added at SignalCommandMap instantiation.</p></div>ZackPiercetag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-15T18:00:43Z2010-11-15T18:00:43ZIssue with signalCommandMap<div><p>thanks guys, my context is doing this</p>
<p>All my other signals get injected fine into my mediators</p>
<p>package<br />
{</p>
<pre><code>import controller.AddCommentCommand;
import controller.AddReviewCommand;
import controller.AuthenticateLoginCommand;
import controller.GetApplicationDataCommand;
import controller.GetSelectedApplicationUserDataCommand;
import model.CommentsModel;
import model.ReviewModel;
import model.UserModel;
import org.robotlegs.base.ContextEvent;
import org.robotlegs.mvcs.Context;
import org.robotlegs.mvcs.SignalContext;
import services.AuthenticationService;
import services.CommentsService;
import services.IAuthenticationService;
import services.ReviewService;
import services.UsersService;
import signalz.GetAppDataSignal;
import views.AddComments;
import views.AddCommentsMediator;
import views.ApplicationMediator;
import views.LoginForm;
import views.LoginFormMediator;
import views.RatingView;
import views.RatingViewMediator;
import views.events.LDAP_LoginEvent;
import views.signalz.AddCommentSignal;
import views.signalz.AddReview;
import views.signalz.ApplicationUserChanged;
public class PR_SUITE_Context extends SignalContext
{
override public function startup():void
{
//model
injector.mapSingleton(CommentsModel);
injector.mapSingleton(UserModel);
injector.mapSingleton(ReviewModel);
//service
injector.mapSingletonOf(IAuthenticationService, AuthenticationService);
injector.mapSingleton(CommentsService);
injector.mapSingleton(UsersService);
injector.mapSingleton(ReviewService);
//view
mediatorMap.mapView(LoginForm, LoginFormMediator);
mediatorMap.mapView(AddComments, AddCommentsMediator);
mediatorMap.mapView(PR_SUITE, ApplicationMediator);
mediatorMap.mapView(RatingView, RatingViewMediator);
//Command
commandMap.mapEvent(LDAP_LoginEvent.LOGIN,AuthenticateLoginCommand);
signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
signalCommandMap.mapSignalClass(AddReview,AddReviewCommand);
signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);
signalCommandMap.mapSignalClass(GetAppDataSignal,GetApplicationDataCommand);
dispatchEvent(new ContextEvent(ContextEvent.STARTUP));
}
}</code></pre>
<p>}</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-15T18:11:16Z2010-11-15T18:11:16ZIssue with signalCommandMap<div><p>Hi Zack,</p>
<p>I'm sure you're right - my fork of SignalCommandMap that I use is old and pre childInjector stuff.</p>
<p>Thanks,</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-15T18:20:55Z2010-11-15T18:20:55ZIssue with signalCommandMap<div><blockquote><p>my fork of SignalCommandMap that I use is old and pre childInjector stuff.</p></blockquote>
<p>That very well might be the answer Nikos needs. Nikos, is your SignalCommandMap swc/source up-to-date?</p></div>ZackPiercetag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-22T15:47:43Z2010-11-22T15:47:43ZIssue with signalCommandMap<div><p>thanks but all is up to date and still the problem. :(</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-22T17:59:00Z2010-11-22T17:59:00ZIssue with signalCommandMap<div><p>btw im using the SignalCommandMap source, where is the swc?</p>
<p>it seems the injection is been attempted before this line of code is being called</p>
<p>signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-23T10:31:57Z2010-11-23T10:31:57ZIssue with signalCommandMap<div><p>perhaps the problem is that this mediator is mediating the
contextView?</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/38083772010-11-23T11:31:41Z2010-11-23T11:31:41ZIssue with signalCommandMap<div><p>Fixed it by reversing these:</p>
<p>//view</p>
<pre>
<code> mediatorMap.mapView(LoginForm, LoginFormMediator);
mediatorMap.mapView(AddComments, AddCommentsMediator);
mediatorMap.mapView(PR_SUITE, ApplicationMediator);
mediatorMap.mapView(RatingView, RatingViewMediator);
//Command
commandMap.mapEvent(LDAP_LoginEvent.LOGIN,AuthenticateLoginCommand);
signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
signalCommandMap.mapSignalClass(AddReview,AddReviewCommand);
signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);</code>
</pre></div>Nikos