Title: Trouble strongly typing custom Notifications Post by: robmccardle on March 23, 2009, 05:55:51 Hi all, first of all this is an amazing library thank you so much Darshan for your excellent work. I'm studying http://code.google.com/p/fabrication/wiki/ReflexiveNotificationInterests but having trouble strongly typing my notifications as it won't compile. The error I get is: "Incompatible types String and ContextMenuNotification. 'newContextMenuNotification(ContextMenuNotification.ADD_MENU)'" Here is the Command code that the error happens in: public class BossStartupCommand extends SimpleFabricationCommand { In my Mediator I have a respondTo function which works fine with INotification as the argument & a vanilla Notification is sent but never gets called when I swap it for my strongly typed version:
My Notification is simple and is extending the Fabrication version, here's the code:
I am using the latest versions of PureMVC Multicore, Pipes & Fabrication with Flash (Not Flex) in FDT. Can anyone point out what I'm doing wrong please? Many thanks :) Title: Re: Trouble strongly typing custom Notifications Post by: Darshan Sawardekar on March 23, 2009, 08:42:09 @robmccardle, Thanks for trying Fabrication.
I haven't changed the sendNotification signature in Fabrication from the one in PureMVC. This can't be done in as3 because the override modifier does not allow changing the signature of a method implemented in a parent class. The PureMVC classes implement the sendNotification signature typed to string. You need to use notifyObservers(new ContextMenuNotification(ContextMenuNotification.ADD_MENU)); Then if you use Reflexive notification interests then with a respondTo like, public function respondToAddMenu(note:ContextMenuNotification):void { you do not need to cast note to ContextMenuNotification. If this were a routed notification then routeNotification supports both string and custom INotification arguments. peace, darshan Title: Re: Trouble strongly typing custom Notifications Post by: robmccardle on March 23, 2009, 10:00:35 Magic, I got it working and your explanation makes perfect sense. Cheers for the quick response too! Kind Regards, Rob |