Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
I prefer storing the notification constants in the classes which the notification triggers.
com.me.myapp.ApplicationFacadecom.me.myapp.ApplicationConstantscom.me.myapp.controller.StartupCommandcom.me.myapp.model.*com.me.myapp.model.vo.*com.me.myapp.view.*com.me.myapp.view.components.*
package com.me.myapp{ import com.me.myapp.controller.StartupCommand; import org.puremvc.as3.patterns.facade.Facade; public static const STARTUP:String = "/note/startup"; public function ApplicationFacade( ) { super(); } public static function getInstance() : ApplicationFacade { if ( instance == null ) instance = new ApplicationFacade( ); return instance as ApplicationFacade; } override protected function initializeController():void { super.initializeController(); registerCommand( STARTUP, StartupCommand ); // Register your initial commands here... } public function startup( app:Object ):void { sendNotification( STARTUP, app ); }}
package com.me.myapp.view{ import com.me.myapp.ApplicationConstants; import com.me.myapp.view.components.*; import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.mediator.Mediator; public class SomeMediator extends Mediator { public static const NAME:String = 'SomeMediator'; public function SomeMediator( viewComponent:Object ) { super( NAME, viewComponent ); } override public function onRegister():void { // Add your initialization activities here not in the constructor // Add event listeners to your component, fetch references to // frequently accessed proxies, etc. } override public function listNotificationInterests():Array { return [ //ApplicationConstants.SOME_NOTE ]; } override public function handleNotification( note:INotification ):void { /* switch ( note.getName() ) { case ApplicationConstants.SOME_NOTE: myComponent.someProp = note.getBody() as SomeClass; break; } */ } override public function onRemove():void { // Remove any listeners, null component references, etc. } protected function get myComponent():MyComponent { return viewComponent as MyComponent; } }}
package com.me.myapp.model{ import org.puremvc.as3.patterns.proxy.Proxy; public class SomeProxy extends Proxy { public static const NAME:String = 'SomeProxy'; public function SomeProxy( ) { super ( NAME ); } override public function onRegister():void { // Add your initialization activities here not in the constructor // Add services or delegates and their event listeners, etc. } override public function onRemove():void { // Remove any listeners, null references, etc. }}
package com.me.myapp.controller{ import com.me.myapp.ApplicationConstants; import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.command.SimpleCommand; public class StartupCommand extends SimpleCommand { override public function execute(note:INotification):void { // Prepare the Model //facade.registerProxy( new SomeProxy() ); // Prepare the View //var app:Shell = note.getBody() as Shell; //facade.registerMediator( new ShellMediator( app ) ); } }}
package com.me.myapp.controller{ import org.puremvc.as3.interfaces.*; import org.puremvc.as3.patterns.command.*; public class SomeMacroCommand extends MacroCommand { override protected function initializeMacroCommand() :void { //Add your subcommands here //addSubCommand( SomeSubCommand ); } }}
com.me.myapp.common.ApplicationConstantscom.me.myapp.common.model.*com.me.myapp.common.view.*com.me.myapp.shell.ShellFacadecom.me.myapp.shell.controller.StartupCommandcom.me.myapp.shell.model.*com.me.myapp.shell.view.*com.me.myapp.shell.view.components.*com.me.myapp.modulea.ModuleAFacadecom.me.myapp.modulea.controller.StartupCommandcom.me.myapp.modulea.model.*com.me.myapp.modulea.view.*com.me.myapp.moduleb.ModuleBFacadecom.me.myapp.moduleb.controller.StartupCommandcom.me.myapp.moduleb.model.*com.me.myapp.moduleb.view.*
package com.me.myapp.shell { import com.me.myapp.shell.controller.StartupCommand; import org.puremvc.as3.multicore.patterns.facade.Facade; public static const STARTUP:String = "/note/startup"; public function ApplicationFacade( key:String ) { super(key); } public static function getInstance( key:String ) : ApplicationFacade { if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade( key ); return instanceMap[ key ] as ApplicationFacade; } override protected function initializeController():void { super.initializeController(); registerCommand( STARTUP, StartupCommand ); // Register your initial commands here... } public function startup( app:Object ):void { sendNotification( STARTUP, app ); }}
package com.me.myapp.shell.view{ import com.me.myapp.common.ApplicationConstants; import com.me.myapp.view.components.*; import org.puremvc.as3.multicore.interfaces.INotification; import org.puremvc.as3.multicore.patterns.mediator.Mediator; public class SomeMediator extends Mediator { public static const NAME:String = 'SomeMediator'; public function SomeMediator( viewComponent:Object ) { super( NAME, viewComponent ); } override public function onRegister():void { // Add your initialization activities here not in the constructor // Add event listeners to your component, fetch references to // frequently accessed proxies, etc. } override public function listNotificationInterests():Array { return [ //ApplicationConstants.SOME_NOTE ]; } override public function handleNotification( note:INotification ):void { /* switch ( note.getName() ) { case ApplicationConstants.SOME_NOTE: myComponent.someProp = note.getBody() as SomeClass; break; } */ } override public function onRemove():void { // Remove any listeners, null component references, etc. } protected function get myComponent():MyComponent { return viewComponent as MyComponent; } }}
package com.me.myapp.shell.model{ import org.puremvc.as3.multicore.patterns.proxy.Proxy; public class SomeProxy extends Proxy { public static const NAME:String = 'SomeProxy'; public function SomeProxy( ) { super ( NAME ); } override public function onRegister():void { // Add your initialization activities here not in the constructor // Add services or delegates and their event listeners, etc. } override public function onRemove():void { // Remove any listeners, null references, etc. }}
package com.me.myapp.shell.controller{ import com.me.myapp.common.ApplicationConstants; import org.puremvc.as3.multicore.interfaces.INotification; import org.puremvc.as3.multicore.patterns.command.SimpleCommand; public class StartupCommand extends SimpleCommand { override public function execute(note:INotification):void { // Prepare the Model //facade.registerProxy( new SomeProxy() ); // Prepare the View //var app:Shell = note.getBody() as Shell; //facade.registerMediator( new ShellMediator( app ) ); } }}
package com.me.myapp.shell.controller{ import org.puremvc.as3.multicore.interfaces.*; import org.puremvc.as3.multicore.patterns.command.*; public class SomeMacroCommand extends MacroCommand { override protected function initializeMacroCommand() :void { //Add your subcommands here //addSubCommand( SomeSubCommand ); } }}