Can Cairngorm and Modules play nice? Sample App
First I'd like to say thanks to those of you that commented on my previous blog entry. I was inspired to go back and take another look at ApplicationDomain. To be honest, I can't get it to work for me. So I'm just going to put up my prototype application with source code and let you play with it. There is a shell application and 3 very simple modules. The challenge is to have a controller in the shell and still have the modules all work independently of each other. The sample app as it sits on the server works because it's essentially Cairngorm free. Good luck!
Source can be found here. Demo can be viewed here.
1 comment:
Vic, I recently came across the very same problem you're having with casting CairngormEvents back to their respective types.
This is from Michael Labriola and he has been helping me with this issue:
"Basically, this is a linker/type issue at heart. Here is the basic idea:
The main application does not know about the event types used in the modules, so, in this case. The main app does have its copy of the CairngormEvent though. The modules also have their own copy of the CairngormEvent, albeit the way the linker works, if two classes have the same name, only the newer wins... I think this is where things start to get bad.
When we try to cast the CairngormEvent back to the specific class it fails the cast because it does not believe they are from the same base class. The two ways we can solve seem to be to ensure we only have one reference to any class (preferred long term method) or to let the main app know about our actual events so that it can pass them along gracefully (quick and dirty albeit somewhat dumb.)
In the case of this example, if we actually add two variables to the main application mxml or code-behind .as file like so:
private var link1:Module2TemplateEvent;
private var link2:Module1TemplateEvent;
The linker includes the definition for these events in the main application and hence everyone is happy when they get passed around."
So, that's basically it in a nutshell.
Thanks,
Thomas
Post a Comment