SwfSuspenders XML config field name values when using Signals
Hi
I'm a bit confused as to how my XML config file would change when
switching over to Signals.
Right now the 3 framework Commands I am using are defined as follows. Both ViewChangedCommand and the InitViewCommand are mapped to custom events.
Comments are currently closed for this discussion. You can start a new one.
2 Posted by eco_bach on 10 Apr, 2010 09:24 PM
Sorry, code didn't make it thru
Support Staff 3 Posted by Shaun Smith on 15 Apr, 2010 09:59 AM
By "switching over to Signals" do you mean using Signals to trigger Commands via Joel's SignalCommandMap?
4 Posted by eco_bach on 15 Apr, 2010 12:45 PM
Yes, exactly. I'm extending SignalContext for my ApplicationContext class.
Support Staff 5 Posted by Shaun Smith on 15 Apr, 2010 12:56 PM
In that case, your Commands will be bound to Signals (not Events), and your XML fields will reference the Signal payload (not Event). I haven't played with the SignalCommandMap, so I'm not the best person to give advice. I assume you've read this:
http://joelhooks.com/2010/02/14/robotlegs-as3-signals-and-the-signa...
I do wonder why you are using the XML config in the first place. Are you compiling with the Flash IDE? Seems like a lot of effort to me!
6 Posted by Jim B on 15 Apr, 2010 01:27 PM
Shaun
Yes I realize the advantages of compiling within FlexFlashbuilder, but most
of my projects are design-asset heavy, with many design revisions.
Perhaps I should consider exporting all my assets as swcs from Flash, then
compile in FB, but this would just require one extra step every time there
is a design revision.
If you think I'm incorrect in still using Flash to compile considering the
above, I'd appreciate your feedback.
My goal is simply to get a working RobotLegs+SWFSuspenders+AS3Signals
template I can extend and use on other projects.
Support Staff 7 Posted by Shaun Smith on 15 Apr, 2010 01:45 PM
There's no correct or incorrect way to do things: whatever works best for you. Personally, I do the export-to-swc technique for my assets as I spend more time compiling after code changes than compiling after design changes. But this may not be the case for you.
I just find the XML config rather laborious. Another approach for Flash IDE compiled projects is to make use of constructor injection for your dependencies. Instead of doing this (which requires metadata):
You could do this:
protected var dep:Dep; public function MyClass( dep:Dep ) { // store the dependency for later use this.dep = dep; }SwiftSuspenders doesn't need metadata to realize that it needs to perform constructor injection. The downside with this approach is that without metadata you can't have "named" injections. Also, it's more long winded than setter injection.
If you do decide to try the constructor injection approach for use with the Flash IDE, be aware that you might still need to pass XML through to the SwiftSuspendersInjector - even if that XML object is empty - in order to set up the default injection points for the MVCS actors. I'm not 100% sure about this though, it might not be necessary.
8 Posted by Jim B on 15 Apr, 2010 02:24 PM
ok thanks, will try that, recall RPenner saying something similar in one of
his posts
9 Posted by Jim B on 15 Apr, 2010 04:50 PM
Shaun
Is there a working RL example you can refer me to using only constructor
instead of property injection?
Support Staff 10 Posted by Shaun Smith on 15 Apr, 2010 07:47 PM
Aha, so, after trying to put together a quick demo, I notice that one still needs to define the injection points via XML for the default MVCS dependencies - I assumed that the default XML map would cover derived classes (descendants of Actor, Mediator etc) but that doesn't seem to be the case.. which is a total pain.
11 Posted by Jim B on 15 Apr, 2010 09:04 PM
ok, thanks for trying.
So bottom line is, if I want to use Robotlegs and compile in the IDE, I
cannot use AS3 signals
The corollary being, if I want to use AS3Signals AND Robotlegs, I cannot
compile using the IDE
Support Staff 12 Posted by Shaun Smith on 16 Apr, 2010 01:00 PM
Hi Jim,
What I was getting at in my last post was that even if you use constructor injection for your actors you still need to provide a minimal XML map to cover the base injections - which isn't much of a time saver. It wasn't related to Signals at all.
Signals, as far as I'm aware, should work just fine. You'd need to change your XML a little: instead of injecting events into your commands, the SignalCommandMap injects the payloads directly. So, for example:
"payload" would be the injection point of the Signal's payload (rather than the Signal itself).
Support Staff 13 Posted by Shaun Smith on 16 Apr, 2010 01:05 PM
More specifically: if we take another look at Joel's post:
http://joelhooks.com/2010/02/14/robotlegs-as3-signals-and-the-signa...
We can see that
AddFoodItemToOrderis a custom Signal that hasFoodTypeas a payload. The corresponding CommandAddFoodItemToOrderCommandgets injected with aFoodType(the payload, not a Signal). The XML mapping might look something like:Does that help at all?
14 Posted by Jim B on 17 Apr, 2010 05:49 PM
Thanks Shaun
sorry for the delayed reply
FINALLY have a working RL+ Swiftsuspenders + AS3 template working. Seems
like magic when it finally works;)
I think I stumbled a bit when I saw 'event in the XML config file, thinking
it had to be 'typed' to Event, and therefore how would I type to 'Signal'?
This is my modified XML config, all I needed to do was add entries for 2 new
signal instances, inited, and updated.
Question: Right now I add signal listeners in my mediator onRegister method.
I see Joel makes use of [postconstruct] with a method to add signal
listeners in an example.
Could I also use postconstruct in my mediators for adding signal listeners?
<types>
<type name='app.model::DataService'>
<field name='model'/>
<field name='inited'/>
</type>
<type name='app.model::SiteModel'>
<field name='updated'/>
</type>
<type name='app.view::BaseMediator'>
<field name='view'/>
<field name='siteModel'/>
<field name='updated'/>
</type>
<type name='app.controller::StartupCommand'>
<field name='dataService'/>
</type>
<type name='app.controller::InitViewCommand'>
<field name='model'/>
</type>
<type name='app.controller::ViewChangedCommand'>
<field name='event'/>
<field name='model'/>
</type>
</types>;
15 Posted by Jos Yule on 18 Apr, 2010 02:58 PM
I should also add, that i've developed an AIR application to create the XML config file for you - you just point it at the root of your class file structure, and it recurses though the files, generating the XML.
I'm in the process of cleaning it up and releasing it (again), if you are interested.
jos
16 Posted by Jim B on 18 Apr, 2010 03:02 PM
sure, sounds awesome!
Support Staff 17 Posted by Shaun Smith on 11 May, 2010 03:44 PM
Hang on a sec.. It seem that compiling with Flash CS3/4/5 might work after all. In your Flash project, under Publish Settings:
Set "Export SWC" to true
Add Robotlegs and SwiftSuspenders source to your Source Path
Compile
I just tested it with a simple project and it worked! Can anyone else confirm this?
Shaun Smith closed this discussion on 20 Jun, 2010 04:16 PM.