From 0a88338eb77737ebb3086a9efd382b61ee749254 Mon Sep 17 00:00:00 2001 From: Allan Dowdeswell Date: Tue, 21 Jun 2016 15:44:39 -0600 Subject: [PATCH] Modified to use PureMVC from Haxelib. Now at version 1.1.0. --- examples/ebook/compile.hxml | 4 +- examples/ebook/project.xml | 1 + haxelib.json | 11 +- src/org/puremvc/haxe/ImportAll.hx | 37 --- src/org/puremvc/haxe/core/Controller.hx | 135 --------- src/org/puremvc/haxe/core/Model.hx | 106 ------- src/org/puremvc/haxe/core/View.hx | 221 --------------- src/org/puremvc/haxe/interfaces/ICommand.hx | 17 -- .../puremvc/haxe/interfaces/IController.hx | 50 ---- src/org/puremvc/haxe/interfaces/IFacade.hx | 93 ------- src/org/puremvc/haxe/interfaces/IMediator.hx | 75 ----- src/org/puremvc/haxe/interfaces/IModel.hx | 41 --- .../puremvc/haxe/interfaces/INotification.hx | 67 ----- src/org/puremvc/haxe/interfaces/INotifier.hx | 34 --- src/org/puremvc/haxe/interfaces/IObserver.hx | 59 ---- src/org/puremvc/haxe/interfaces/IProxy.hx | 52 ---- src/org/puremvc/haxe/interfaces/IView.hx | 70 ----- .../haxe/patterns/command/MacroCommand.hx | 95 ------- .../haxe/patterns/command/SimpleCommand.hx | 33 --- .../puremvc/haxe/patterns/facade/Facade.hx | 259 ------------------ .../haxe/patterns/mediator/Mediator.hx | 105 ------- .../haxe/patterns/observer/Notification.hx | 109 -------- .../haxe/patterns/observer/Notifier.hx | 50 ---- .../haxe/patterns/observer/Observer.hx | 93 ------- src/org/puremvc/haxe/patterns/proxy/Proxy.hx | 88 ------ 25 files changed, 10 insertions(+), 1895 deletions(-) delete mode 100644 src/org/puremvc/haxe/ImportAll.hx delete mode 100644 src/org/puremvc/haxe/core/Controller.hx delete mode 100644 src/org/puremvc/haxe/core/Model.hx delete mode 100644 src/org/puremvc/haxe/core/View.hx delete mode 100644 src/org/puremvc/haxe/interfaces/ICommand.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IController.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IFacade.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IMediator.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IModel.hx delete mode 100644 src/org/puremvc/haxe/interfaces/INotification.hx delete mode 100644 src/org/puremvc/haxe/interfaces/INotifier.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IObserver.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IProxy.hx delete mode 100644 src/org/puremvc/haxe/interfaces/IView.hx delete mode 100644 src/org/puremvc/haxe/patterns/command/MacroCommand.hx delete mode 100644 src/org/puremvc/haxe/patterns/command/SimpleCommand.hx delete mode 100644 src/org/puremvc/haxe/patterns/facade/Facade.hx delete mode 100644 src/org/puremvc/haxe/patterns/mediator/Mediator.hx delete mode 100644 src/org/puremvc/haxe/patterns/observer/Notification.hx delete mode 100644 src/org/puremvc/haxe/patterns/observer/Notifier.hx delete mode 100644 src/org/puremvc/haxe/patterns/observer/Observer.hx delete mode 100644 src/org/puremvc/haxe/patterns/proxy/Proxy.hx diff --git a/examples/ebook/compile.hxml b/examples/ebook/compile.hxml index e9da8ec..54fd101 100644 --- a/examples/ebook/compile.hxml +++ b/examples/ebook/compile.hxml @@ -3,4 +3,6 @@ -cp src -lib openfl -lib svg --lib actuate \ No newline at end of file +-lib actuate +-lib glory +-lib puremvc-standard \ No newline at end of file diff --git a/examples/ebook/project.xml b/examples/ebook/project.xml index f6b1659..8cac845 100644 --- a/examples/ebook/project.xml +++ b/examples/ebook/project.xml @@ -14,6 +14,7 @@ + diff --git a/haxelib.json b/haxelib.json index 69a8b39..e760023 100644 --- a/haxelib.json +++ b/haxelib.json @@ -5,12 +5,13 @@ "description": "Glory Framework is a page-based media framework built using [Haxe 3](http://haxe.org/), [OpenFL](http://openfl.org), and [PureMVC](http://puremvc.org/). It can be used for interactive e-books, adventure games, websites, or slide presentations on any target supported by OpenFL. It uses an XML configuration file to build the layout of each page, including placement and function of different controls. Each page can have its own custom class if desired. Glory also includes two Photoshop scripts which make it easy to rapidly convert a PSD layout into something that Glory can use. It can also use SVG files saved directly from Illustrator (not all types of object are supported).", "contributors": ["ConfidantCommunications"], "classPath":"src/", - "releasenote": "Initial release. ", - "version": "1.0.0", + "releasenote": "Modified to use PureMVC from Haxelib.", + "version": "1.1.0", "url": "https://github.com/ConfidantCommunications/Glory-Framework/", "dependencies": { - "openfl" :"", - "actuate" :"", - "svg" :"" + "openfl" :"", + "actuate" :"", + "svg" :"", + "puremvc-standard":"" } } diff --git a/src/org/puremvc/haxe/ImportAll.hx b/src/org/puremvc/haxe/ImportAll.hx deleted file mode 100644 index a45afa0..0000000 --- a/src/org/puremvc/haxe/ImportAll.hx +++ /dev/null @@ -1,37 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe; - -// core -import org.puremvc.haxe.core.Controller; -import org.puremvc.haxe.core.Model; -import org.puremvc.haxe.core.View; - -// interfaces -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.IController; -import org.puremvc.haxe.interfaces.IFacade; -import org.puremvc.haxe.interfaces.IMediator; -import org.puremvc.haxe.interfaces.IModel; -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.interfaces.IObserver; -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.IProxy; -import org.puremvc.haxe.interfaces.IView; - -// patterns -import org.puremvc.haxe.patterns.command.MacroCommand; -import org.puremvc.haxe.patterns.command.SimpleCommand; -import org.puremvc.haxe.patterns.facade.Facade; -import org.puremvc.haxe.patterns.mediator.Mediator; -import org.puremvc.haxe.patterns.observer.Notification; -import org.puremvc.haxe.patterns.observer.Notifier; -import org.puremvc.haxe.patterns.observer.Observer; -import org.puremvc.haxe.patterns.proxy.Proxy; - - - diff --git a/src/org/puremvc/haxe/core/Controller.hx b/src/org/puremvc/haxe/core/Controller.hx deleted file mode 100644 index 620162d..0000000 --- a/src/org/puremvc/haxe/core/Controller.hx +++ /dev/null @@ -1,135 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.core; - -import org.puremvc.haxe.core.View; -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.IView; -import org.puremvc.haxe.interfaces.IController; -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.patterns.observer.Observer; - -/** - * A Singleton [IController] implementation. - * - *

In PureMVC, the [Controller] class follows the - * 'Command and Controller' strategy, and assumes these responsibilities:

- *
    - *
  • Remembering which [ICommand]s are intended to handle which [INotifications].
  • - *
  • Registering itself as an [IObserver] with the [View] for each [INotification] - * that it has an [ICommand] mapping for.
  • - *
  • Creating a new instance of the proper [ICommand] to handle a given [INotification] - * when notified by the [View].
  • - *
  • Calling the [ICommand]'s [execute] method, passing in the [INotification].
  • - *
- * - *

Your application must register [ICommands] with the Controller. - * The simplest way is to subclass [Facade], - * and use its [initializeController] method to add your registrations.

- */ -class Controller implements IController -{ - - /** - * Constructor. - * - *

This [IController] implementation is a Singleton, so you cannot - * call the constructor directly, but instead call the static Singleton - * Factory method [Controller.getInstance()]

- */ - private function new() - { - instance = this; - commandMap = new Map(); - initializeController(); - } - - /** - * Initialize the Singleton [Controller] instance. - * - *

Called automatically by the constructor.

- * - *

Note that if you are using a subclass of [View] - * in your application, you should also subclass [Controller] - * and override the [initializeController] method. - */ - private function initializeController(): Void - { - view = View.getInstance(); - } - - /** - * [Controller] Singleton Factory method. - */ - public static function getInstance(): IController - { - if ( instance == null ) instance = new Controller(); - return instance; - } - - /** - * If an [ICommand] has previously been registered - * to handle a the given [INotification], then it is executed. - */ - public function executeCommand( note: INotification ): Void - { - var commandClassRef: Class = commandMap.get( note.getName() ); - if ( commandClassRef == null ) return; - - var commandInstance: ICommand = Type.createInstance( commandClassRef, [] ); - commandInstance.execute( note ); - } - - /** - * Register a particular [ICommand] class as the handler for a particular [INotification]. - * - *

If an [ICommand] has already been registered to - * handle [INotification]s with this name, it is no longer - * used, the new [ICommand] is used instead.

- * - *

The Observer for the new ICommand is only created if this the - * first time an ICommand has been regisered for this Notification name.

- */ - public function registerCommand( notificationName: String, commandClassRef: Class ): Void - { - if ( !commandMap.exists( notificationName ) ) - view.registerObserver( notificationName, new Observer( executeCommand, this ) ); - commandMap.set( notificationName, commandClassRef ); - } - - /** - * Check if a Command is registered for a given Notification - */ - public function hasCommand( notificationName: String ): Bool - { - return commandMap.exists( notificationName ); - } - - /** - * Remove a previously registered [ICommand] to [INotification] mapping. - */ - public function removeCommand( notificationName: String ): Void - { - // if the Command is registered... - if ( hasCommand( notificationName ) ) - { - // remove the observer - view.removeObserver( notificationName, this ); - - commandMap.remove( notificationName ); - } - } - - // Local reference to View - private var view: IView; - - // Mapping of Notification names to Command Class references - private var commandMap: Map>; - - // Singleton instance - private static var instance: IController; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/core/Model.hx b/src/org/puremvc/haxe/core/Model.hx deleted file mode 100644 index 5a2748c..0000000 --- a/src/org/puremvc/haxe/core/Model.hx +++ /dev/null @@ -1,106 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.core; - -import org.puremvc.haxe.interfaces.IModel; -import org.puremvc.haxe.interfaces.IProxy; - -/** - * A Singleton [IModel] implementation. - * - *

In PureMVC, the [Model] class provides access to model objects (Proxies) by named lookup.

- * - *

The [Model] assumes these responsibilities:

- *
    - *
  • Maintain a cache of [IProxy] instances.
  • - *
  • Provide methods for registering, retrieving, and removing [IProxy] instances.
  • - *
- * - *

Your application must register [IProxy] instances with the [Model]. Typically, you use an - * [ICommand] to create and register [IProxy] instances once the [Facade] has initialized the Core - * actors.

- */ -class Model implements IModel -{ - /** - * Constructor. - * - *

This [IModel] implementation is a Singleton, so you should not call the constructor - * directly, but instead call the static Singleton Factory method [Model.getInstance()]

- */ - // Mapping of proxyNames to [IProxy] instances - private var proxyMap: Map; - - // Singleton instance - private static var instance: IModel; - private function new() - { - instance = this; - proxyMap = new Map(); - initializeModel(); - } - - /** - * Initialize the Singleton [Model] instance. - * - *

Called automatically by the constructor, this is your opportunity to initialize the Singleton - * instance in your subclass without overriding the constructor.

- */ - private function initializeModel(): Void - { - } - - /** - * [Model] Singleton Factory method. - */ - public static function getInstance(): IModel - { - if ( instance == null ) instance = new Model(); - return instance; - } - - /** - * Register an [IProxy] with the [Model]. - */ - public function registerProxy( proxy: IProxy ): Void - { - proxyMap.set( proxy.getProxyName(), proxy ); - proxy.onRegister(); - } - - /** - * Retrieve an [IProxy] from the [Model]. - */ - public function retrieveProxy( proxyName: String ): IProxy - { - return proxyMap.get( proxyName ); - } - - /** - * Check if a [Proxy] is registered - */ - public function hasProxy( proxyName:String ) : Bool - { - return proxyMap.exists( proxyName ); - } - - /** - * Remove an [IProxy] from the [Model]. - */ - public function removeProxy( proxyName: String ): IProxy - { - var proxy: IProxy = proxyMap.get( proxyName ); - if ( proxy != null ) - { - proxyMap.remove( proxyName ); - proxy.onRemove(); - } - return proxy; - } - - - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/core/View.hx b/src/org/puremvc/haxe/core/View.hx deleted file mode 100644 index 369f9da..0000000 --- a/src/org/puremvc/haxe/core/View.hx +++ /dev/null @@ -1,221 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.core; - -import org.puremvc.haxe.interfaces.IView; -import org.puremvc.haxe.interfaces.IObserver; -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.IMediator; -import org.puremvc.haxe.patterns.observer.Observer; - -// import org.puremvc.haxe.patterns.observer.Observer; - -/** - * A Singleton [IView] implementation. - * - *

In PureMVC, the [View] class assumes these responsibilities:

- *
    - *
  • Maintain a cache of [IMediator] instances.
  • - *
  • Provide methods for registering, retrieving, and removing [IMediators].
  • - *
  • Managing the observer lists for each [INotification] in the application.
  • - *
  • Providing a method for attaching [IObservers] to an [INotification]'s observer list.
  • - *
  • Providing a method for broadcasting an [INotification].
  • - *
  • Notifying the [IObservers] of a given [INotification] when it broadcast.
  • - *
- */ -class View implements IView -{ - /** - * Constructor. - * - *

This [IView] implementation is a Singleton, - * so you should not call the constructor - * directly, but instead call the static Singleton - * Factory method [View.getInstance()]

- */ - // Mapping of Mediator names to Mediator instances - private var mediatorMap: Map; - - // Mapping of Notification names to Observer lists - private var observerMap: Map>; - - // Singleton instance - private static var instance : IView; - public function new() - { - instance = this; - mediatorMap = new Map(); - observerMap = new Map(); - initializeView(); - } - - /** - * Initialize the Singleton [View] instance. - * - *

Called automatically by the constructor, this is your opportunity to initialize the Singleton - * instance in your subclass without overriding the constructor.

- */ - private function initializeView(): Void - { - } - - /** - * View Singleton Factory method. - */ - public static function getInstance(): IView - { - if ( instance == null ) instance = new View(); - return instance; - } - - /** - * Register an [IObserver] to be notified of [INotifications] with a given name. - */ - public function registerObserver( notificationName: String, observer: IObserver ): Void - { - if( !observerMap.exists( notificationName ) ) - observerMap.set( notificationName, new List() ); - observerMap.get( notificationName ).add( observer ); - } - - /** - * Notify the [IObservers] for a particular [INotification]. - * - *

All previously attached [IObservers] for this [INotification]'s - * list are notified and are passed a reference to the [INotification] in - * the order in which they were registered.

- */ - public function notifyObservers( notification: INotification ): Void - { - if( observerMap.exists( notification.getName() ) ) - { - // Get a reference to the observers list for this notification name - var observers_ref: List = observerMap.get( notification.getName() ); - - // Copy observers from reference array to working array, - // since the reference array may change during the notification loop - var observers: List = new List(); - var iterator_ref: Iterator = observers_ref.iterator(); - for ( observer in iterator_ref ) - observers.add( observer ); - - var iterator: Iterator = observers.iterator(); - for ( observer in iterator ) - observer.notifyObserver( notification ); - } - } - - /** - * Remove the observer for a given notifyContext from an observer list for a given Notification name. - */ - public function removeObserver( notificationName: String, notifyContext: Dynamic ): Void - { - // the observer list for the notification under inspection - var observers: List = observerMap.get( notificationName ); - - // find the observer for the notifyContext - for ( observer in observers.iterator() ) - { - if ( observer.compareNotifyContext( notifyContext ) == true ) - { - // there can only be one Observer for a given notifyContext - // in any given Observer list, so remove it and break - observers.remove( observer ); - break; - } - } - - // Also, when a Notification's Observer list length falls to - // zero, delete the notification key from the observer map - if ( observers.isEmpty() ) - { - observerMap.remove( notificationName ); - } - } - - /** - * Register an [IMediator] instance with the [View]. - * - *

Registers the [IMediator] so that it can be retrieved by name, - * and further interrogates the [IMediator] for its [INotification] interests.

- *

- * If the [IMediator] returns any [INotification] - * names to be notified about, an [Observer] is created encapsulating - * the [IMediator] instance's [handleNotification] method - * and registering it as an [Observer] for all [INotifications] the - * [IMediator] is interested in.

- */ - public function registerMediator( mediator: IMediator ): Void - { - // do not allow re-registration (you must to removeMediator fist) - if ( mediatorMap.exists( mediator.getMediatorName() ) ) return; - - // Register the Mediator for retrieval by name - mediatorMap.set( mediator.getMediatorName(), mediator ); - - // Get Notification interests, if any. - var interests: Array = mediator.listNotificationInterests(); - if ( interests.length > 0) - { - // Create Observer - var observer: Observer = new Observer( mediator.handleNotification, mediator ); - - // Register Mediator as Observer for its list of Notification interests - for ( i in 0...interests.length) - registerObserver( interests[ i ], observer ); - } - - mediator.onRegister(); - } - - /** - * Retrieve an [IMediator] from the [View]. - */ - public function retrieveMediator( mediatorName: String ): IMediator - { - return mediatorMap.get( mediatorName ); - } - - /** - * Remove an [IMediator] from the [View]. - */ - public function removeMediator( mediatorName: String ): IMediator - { - // Retrieve the named mediator - var mediator:IMediator = mediatorMap.get( mediatorName ); - - if ( mediator != null ) - { - // for every notification this mediator is interested in... - var interests: Array = mediator.listNotificationInterests(); - for ( i in 0...interests.length ) - { - // remove the observer linking the mediator - // to the notification interest - removeObserver( interests[ i ], mediator ); - } - - // remove the mediator from the map - mediatorMap.remove( mediatorName ); - - // alert the mediator that it has been removed - mediator.onRemove(); - } - - return mediator; - } - - /** - * Check if a Mediator is registered or not - */ - public function hasMediator( mediatorName: String ): Bool - { - return mediatorMap.exists( mediatorName ); - } - - - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/ICommand.hx b/src/org/puremvc/haxe/interfaces/ICommand.hx deleted file mode 100644 index a34df74..0000000 --- a/src/org/puremvc/haxe/interfaces/ICommand.hx +++ /dev/null @@ -1,17 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Command. - */ -interface ICommand -{ - /** - * Execute the [ICommand]'s logic to handle a given [INotification]. - */ - function execute( notification: INotification ): Void; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IController.hx b/src/org/puremvc/haxe/interfaces/IController.hx deleted file mode 100644 index f6e896d..0000000 --- a/src/org/puremvc/haxe/interfaces/IController.hx +++ /dev/null @@ -1,50 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Controller. - * - *

In PureMVC, an [IController] implementor - * follows the 'Command and Controller' strategy, and - * assumes these responsibilities:

- *
    - *
  • Remembering which [ICommand]s - * are intended to handle which [INotifications].
  • - *
  • Registering itself as an [IObserver] with - * the [View] for each [INotification] - * that it has an [ICommand] mapping for.
  • - *
  • Creating a new instance of the proper [ICommand] - * to handle a given [INotification] when notified by the [View].
  • - *
  • Calling the [ICommand]'s [execute] - * method, passing in the [INotification].
  • - *
- */ -interface IController -{ - /** - * Register a particular [ICommand] class as the handler - * for a particular [INotification]. - */ - function registerCommand( notificationName: String, commandClassRef: Class ): Void; - - /** - * Execute the [ICommand] previously registered as the - * handler for [INotification]s with the given notification name. - */ - function executeCommand( notification: INotification ): Void; - - /** - * Remove a previously registered [ICommand] to [INotification] mapping. - */ - function removeCommand( notificationName: String ): Void; - - /** - * Check if a Command is registered for a given Notification - */ - function hasCommand( notificationName: String ): Bool; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IFacade.hx b/src/org/puremvc/haxe/interfaces/IFacade.hx deleted file mode 100644 index 7f4940f..0000000 --- a/src/org/puremvc/haxe/interfaces/IFacade.hx +++ /dev/null @@ -1,93 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Facade. - * - *

The Facade Pattern suggests providing a single - * class to act as a central point of communication - * for a subsystem.

- * - *

In PureMVC, the Facade acts as an interface between - * the core MVC actors (Model, View, Controller) and - * the rest of your application.

- */ -interface IFacade -{ - /** - * Register an [IProxy] with the [Model] by name. - */ - function registerProxy( proxy: IProxy ): Void; - - /** - * Retrieve a [IProxy] from the [Model] by name. - */ - function retrieveProxy( proxyName: String ): IProxy; - - /** - * Remove an [IProxy] instance from the [Model] by name. - */ - function removeProxy( proxyName: String ): IProxy; - - /** - * Check if a [Proxy] is registered - */ - function hasProxy( proxyName: String ): Bool; - - /** - * Register an [ICommand] with the [Controller]. - */ - function registerCommand( noteName: String, commandClassRef: Class ) : Void; - - /** - * Remove a previously registered [ICommand] to [INotification] mapping from the Controller. - */ - function removeCommand( notificationName: String ): Void; - - /** - * Check if a [Command] is registered for a given Notification - */ - function hasCommand( notificationName: String ): Bool; - - /** - * Register an [IMediator] instance with the [View]. - */ - function registerMediator( mediator: IMediator ) :Void; - - /** - * Retrieve an [IMediator] instance from the [View]. - */ - function retrieveMediator( mediatorName: String ): IMediator; - - /** - * Remove a [IMediator] instance from the [View]. - */ - function removeMediator( mediatorName: String ): IMediator; - - /** - * Check if a [Mediator] is registered or not - */ - function hasMediator( mediatorName: String ): Bool; - - /** - * Create and send an [INotification]. - */ - function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void; - - /** - * Notify the [IObservers] for a particular [INotification]. - * - *

All previously attached [IObservers] for this [INotification]'s - * list are notified and are passed a reference to the [INotification] in - * the order in which they were registered.

- * - *

NOTE: Use this method only if you are sending custom Notifications. Otherwise - * use the sendNotification method which does not require you to create the - * Notification instance.

- */ - function notifyObservers( note: INotification ): Void; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IMediator.hx b/src/org/puremvc/haxe/interfaces/IMediator.hx deleted file mode 100644 index ddd3628..0000000 --- a/src/org/puremvc/haxe/interfaces/IMediator.hx +++ /dev/null @@ -1,75 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Mediator. - * - *

In PureMVC, [IMediator] implementors assume these responsibilities:

- *
    - *
  • Implement a common method which returns a list of all [INotification]s - * the [IMediator] has interest in.
  • - *
  • Implement a common notification (callback) method.
  • - *
- *

Additionally, [IMediator]s typically:

- *
    - *
  • Act as an intermediary between one or more view components such as text boxes or - * list controls, maintaining references and coordinating their behavior.
  • - *
  • In Flash-based apps, this is often the place where event listeners are - * added to view components, and their handlers implemented.
  • - *
  • Respond to and generate [INotifications], interacting with of - * the rest of the PureMVC app.
  • - *
- *

When an [IMediator] is registered with the [IView], - * the [IView] will call the [IMediator]'s - * [listNotificationInterests] method. The [IMediator] will - * return an [Array] of [INotification] names which - * it wishes to be notified about.

- * - *

The [IView] will then create an [Observer] object - * encapsulating that [IMediator]'s ([handleNotification]) method - * and register it as an Observer for each [INotification] name returned by - * [listNotificationInterests].

- */ -interface IMediator -{ - - /** - * Get the [IMediator] instance name - */ - function getMediatorName(): String; - - /** - * Get the [IMediator]'s view component. - */ - function getViewComponent(): Dynamic; - - /** - * Set the [IMediator]'s view component. - */ - function setViewComponent( viewComponent: Dynamic ): Void; - - /** - * List [INotification] interests. - */ - function listNotificationInterests(): Array; - - /** - * Handle an [INotification]. - */ - function handleNotification( notification: INotification ): Void; - - /** - * Called by the [View] when the [Mediator] is registered - */ - function onRegister(): Void; - - /** - * Called by the [View] when the [Mediator] is removed - */ - function onRemove(): Void; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IModel.hx b/src/org/puremvc/haxe/interfaces/IModel.hx deleted file mode 100644 index eaecfe7..0000000 --- a/src/org/puremvc/haxe/interfaces/IModel.hx +++ /dev/null @@ -1,41 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Model. - * - *

In PureMVC, [IModel] implementors provide - * access to [IProxy] objects by named lookup.

- * - *

An [IModel] assumes these responsibilities:

- *
    - *
  • Maintain a cache of [IProxy] instances
  • - *
  • Provide methods for registering, retrieving, and removing [IProxy] instances
  • - *
- */ -interface IModel -{ - /** - * Register an [IProxy] instance with the [Model]. - */ - function registerProxy( proxy: IProxy ): Void; - - /** - * Retrieve an [IProxy] instance from the Model. - */ - function retrieveProxy( proxyName: String ): IProxy; - - /** - * Remove an [IProxy] instance from the Model. - */ - function removeProxy( proxyName: String ): IProxy; - - /** - * Check if a [Proxy] is registered - */ - function hasProxy( proxyName: String ): Bool; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/INotification.hx b/src/org/puremvc/haxe/interfaces/INotification.hx deleted file mode 100644 index 491401a..0000000 --- a/src/org/puremvc/haxe/interfaces/INotification.hx +++ /dev/null @@ -1,67 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Notification. - * - *

PureMVC does not rely upon underlying event models such - * as the one provided with Flash.

- * - *

The Observer Pattern as implemented within PureMVC exists - * to support event-driven communication between the - * application and the actors of the MVC triad.

- * - *

Notifications are not meant to be a replacement for Events. - * Generally, [IMediator] implementors - * place event listeners on their view components, which they - * then handle in the usual way. This may lead to the broadcast of [Notification]s to - * trigger [ICommand]s or to communicate with other [IMediators]. [IProxy] and [ICommand] - * instances communicate with each other and [IMediator]s - * by broadcasting [INotification]s.

- * - *

A key difference between Flash [Event]s and PureMVC - * [Notification]s is that [Event]s follow the - * 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy - * until some parent component handles the [Event], while - * PureMVC [Notification]s follow a 'Publish/Subscribe' - * pattern. PureMVC classes need not be related to each other in a - * parent/child relationship in order to communicate with one another - * using [Notification]s. - */ -interface INotification -{ - /** - * Get the name of the [INotification] instance. - * No setter, should be set by constructor only - */ - function getName(): String; - - /** - * Set the body of the [INotification] instance - */ - function setBody( body: Dynamic ): Void; - - /** - * Get the body of the [INotification] instance - */ - function getBody(): Dynamic; - - /** - * Set the type of the [INotification] instance - */ - function setType( type: String ): Void; - - /** - * Get the type of the [INotification] instance - */ - function getType(): String; - - /** - * Get the string representation of the [INotification] instance - */ - function toString(): String; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/INotifier.hx b/src/org/puremvc/haxe/interfaces/INotifier.hx deleted file mode 100644 index e91852b..0000000 --- a/src/org/puremvc/haxe/interfaces/INotifier.hx +++ /dev/null @@ -1,34 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Notifier. - * - *

[MacroCommand, Command, Mediator] and [Proxy] - * all have a need to send [Notifications].

- * - *

The [INotifier] interface provides a common method called - * [sendNotification] that relieves implementation code of - * the necessity to actually construct [Notifications].

- * - *

The [Notifier] class, which all of the above mentioned classes - * extend, also provides an initialized reference to the [Facade] - * Singleton, which is required for the convienience method - * for sending [Notifications], but also eases implementation as these - * classes have frequent [Facade] interactions and usually require - * access to the facade anyway.

- */ -interface INotifier -{ - /** - * Send a [INotification]. - * - *

Convenience method to prevent having to construct new - * notification instances in our implementation code.

- */ - function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IObserver.hx b/src/org/puremvc/haxe/interfaces/IObserver.hx deleted file mode 100644 index c34abc7..0000000 --- a/src/org/puremvc/haxe/interfaces/IObserver.hx +++ /dev/null @@ -1,59 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Observer. - * - *

In PureMVC, [IObserver] implementors assume these responsibilities: - *

    - *
  • Encapsulate the notification (callback) method of the interested object.
  • - *
  • Encapsulate the notification context (this) of the interested object.
  • - *
  • Provide methods for setting the interested object' notification method and context.
  • - *
  • Provide a method for notifying the interested object.
  • - *
- * - *

PureMVC does not rely upon underlying event - * models such as the one provided with Flash.

- * - *

The Observer Pattern as implemented within - * PureMVC exists to support event driven communication - * between the application and the actors of the MVC triad.

- * - *

An Observer is an object that encapsulates information - * about an interested object with a notification method that - * should be called when an [INotification] is broadcast. The Observer then - * acts as a proxy for notifying the interested object. - * - *

Observers can receive [Notification]s by having their - * [notifyObserver] method invoked, passing - * in an object implementing the [INotification] interface, such - * as a subclass of [Notification].

- */ -interface IObserver -{ - /** - * Set the notification method. - * - *

The notification method should take one parameter of type [INotification]

- */ - function setNotifyMethod( notifyMethod: Dynamic -> Void ): Void; - - /** - * Set the notification context. - */ - function setNotifyContext( notifyContext: Dynamic ): Void; - - /** - * Notify the interested object. - */ - function notifyObserver( notification: INotification ): Void; - - /** - * Compare the given object to the notificaiton context object. - */ - function compareNotifyContext( object: Dynamic ): Bool; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IProxy.hx b/src/org/puremvc/haxe/interfaces/IProxy.hx deleted file mode 100644 index f07aa41..0000000 --- a/src/org/puremvc/haxe/interfaces/IProxy.hx +++ /dev/null @@ -1,52 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC Proxy. - * - *

In PureMVC, [IProxy] implementors assume these responsibilities:

- *
    - *
  • Implement a common method which returns the name of the [Proxy].
  • - *
- *

Additionally, [IProxy]s typically:

- *
    - *
  • Maintain references to one or more pieces of model data.
  • - *
  • Provide methods for manipulating that data.
  • - *
  • Generate [INotifications] when their model data changes.
  • - *
  • Expose their name as a [public static var] called [NAME].
  • - *
  • Encapsulate interaction with local or remote services used to fetch and persist model data.
  • - *
- */ -interface IProxy -{ - - /** - * Get the [Proxy] name - */ - function getProxyName(): String; - - /** - * Set the data object - */ - function setData( data: Dynamic ): Void; - - /** - * Get the data object - */ - function getData(): Dynamic; - - /** - * Called by the Model when the [Proxy] is registered - */ - function onRegister(): Void; - - /** - * Called by the Model when the [Proxy] is removed - */ - function onRemove(): Void; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/interfaces/IView.hx b/src/org/puremvc/haxe/interfaces/IView.hx deleted file mode 100644 index 266204f..0000000 --- a/src/org/puremvc/haxe/interfaces/IView.hx +++ /dev/null @@ -1,70 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.interfaces; - -/** - * The interface definition for a PureMVC View. - * - *

In PureMVC, the [View] class assumes these responsibilities: - *

    - *
  • Maintain a cache of [IMediator] instances.
  • - *
  • Provide methods for registering, retrieving, and removing [IMediators].
  • - *
  • Managing the observer lists for each [INotification] in the application.
  • - *
  • Providing a method for attaching [IObservers] to an [INotification]'s observer list.
  • - *
  • Providing a method for broadcasting an [INotification].
  • - *
  • Notifying the [IObservers] of a given [INotification] when it broadcast.
  • - *
- */ -interface IView -{ - /** - * Register an [IObserver] to be notified of [INotifications] with a given name. - */ - function registerObserver ( noteName: String, observer: IObserver ): Void; - - /** - * Remove a group of observers from the observer list for a given Notification name. - */ - function removeObserver( notificationName: String, notifyContext: Dynamic ): Void; - - /** - * Notify the [IObservers] for a particular [INotification]. - * - *

All previously attached [IObservers] for this [INotification]'s - * list are notified and are passed a reference to the [INotification] in - * the order in which they were registered.

- */ - function notifyObservers( note: INotification ): Void; - - /** - * Register an [IMediator] instance with the [View]. - * - *

Registers the [IMediator] so that it can be retrieved by name, - * and further interrogates the [IMediator] for its [INotification] interests.

- * - *

If the [IMediator] returns any [INotification] - * names to be notified about, an [Observer] is created encapsulating - * the [IMediator] instance's [handleNotification] method - * and registering it as an [Observer] for all [INotifications] the - * [IMediator] is interested in.

- */ - function registerMediator( mediator: IMediator ): Void; - - /** - * Retrieve an [IMediator] from the [View]. - */ - function retrieveMediator( mediatorName: String ): IMediator; - - /** - * Remove an [IMediator] from the [View]. - */ - function removeMediator( mediatorName: String ): IMediator; - - /** - * Check if a [Mediator] is registered or not - */ - function hasMediator( mediatorName: String ): Bool; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/command/MacroCommand.hx b/src/org/puremvc/haxe/patterns/command/MacroCommand.hx deleted file mode 100644 index f001d58..0000000 --- a/src/org/puremvc/haxe/patterns/command/MacroCommand.hx +++ /dev/null @@ -1,95 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.command; - -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.patterns.observer.Notifier; - -/** - * A base [ICommand] implementation that executes other [ICommand]s. - * - *

A [MacroCommand] maintains an list of - * [ICommand] Class references called SubCommands.

- * - *

When [execute] is called, the [MacroCommand] - * instantiates and calls [execute] on each of its SubCommands turn. - * Each SubCommand will be passed a reference to the original - * [INotification] that was passed to the [MacroCommand]'s - * [execute] method.

- * - *

Unlike [SimpleCommand], your subclass - * should not override [execute], but instead, should - * override the [initializeMacroCommand] method, - * calling [addSubCommand] once for each SubCommand - * to be executed.

- */ -class MacroCommand extends Notifier implements ICommand -{ - - private var subCommands: List>; - - /** - * Constructor. - * - *

You should not need to define a constructor, - * instead, override the [initializeMacroCommand] - * method.

- * - *

- * If your subclass does define a constructor, be - * sure to call [super()].

- */ - public function new() - { - super(); - subCommands = new List(); - initializeMacroCommand(); - } - - /** - * Initialize the [MacroCommand]. - * - *

In your subclass, override this method to - * initialize the [MacroCommand]'s SubCommand - * list with [ICommand] class references. - * - *

Note that SubCommands may be any [ICommand] implementor, - * [MacroCommand]s or [SimpleCommands] are both acceptable.

- */ - private function initializeMacroCommand(): Void - { - } - - /** - * Add a SubCommand. - * - *

The SubCommands will be called in First In/First Out (FIFO) - * order.

- */ - private function addSubCommand( commandClassRef: Class ): Void - { - subCommands.add( commandClassRef ); - } - - /** - * Execute this [MacroCommand]'s SubCommands. - * - *

The SubCommands will be called in First In/First Out (FIFO) - * order.

- */ - public function execute( notification: INotification ): Void - { - while ( !subCommands.isEmpty() ) - { - var commandClassRef: Class = subCommands.pop(); - var commandInstance: ICommand = Type.createInstance( commandClassRef, [] ); - commandInstance.execute( notification ); - } - } - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/command/SimpleCommand.hx b/src/org/puremvc/haxe/patterns/command/SimpleCommand.hx deleted file mode 100644 index 71eba3b..0000000 --- a/src/org/puremvc/haxe/patterns/command/SimpleCommand.hx +++ /dev/null @@ -1,33 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.command; - -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.patterns.observer.Notifier; - -/** - * A base [ICommand] implementation. - * - *

Your subclass should override the [execute] - * method where your business logic will handle the [INotification].

- */ -class SimpleCommand extends Notifier implements ICommand -{ - /** - * Fulfill the use-case initiated by the given [INotification]. - * - *

In the Command Pattern, an application use-case typically - * begins with some user action, which results in an [INotification] being broadcast, which - * is handled by business logic in the [execute] method of an [ICommand].

- */ - public function execute( notification: INotification ) : Void - { - - } - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/facade/Facade.hx b/src/org/puremvc/haxe/patterns/facade/Facade.hx deleted file mode 100644 index 5881d12..0000000 --- a/src/org/puremvc/haxe/patterns/facade/Facade.hx +++ /dev/null @@ -1,259 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.facade; - -import org.puremvc.haxe.core.View; -import org.puremvc.haxe.core.Model; -import org.puremvc.haxe.core.Controller; -import org.puremvc.haxe.patterns.observer.Notification; -import org.puremvc.haxe.interfaces.IFacade; -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.ICommand; -import org.puremvc.haxe.interfaces.IProxy; -import org.puremvc.haxe.interfaces.IMediator; -import org.puremvc.haxe.interfaces.IController; -import org.puremvc.haxe.interfaces.IModel; -import org.puremvc.haxe.interfaces.IView; - -/** - * A base Singleton [IFacade] implementation. - * - *

In PureMVC, the [Facade] class assumes these - * responsibilities:

- *
    - *
  • Initializing the [Model], [View] and [Controller] Singletons.
  • - *
  • Providing all the methods defined by the [IModel, IView, & IController] interfaces.
  • - *
  • Providing the ability to override the specific [Model], [View] and [Controller] Singletons created.
  • - *
  • Providing a single point of contact to the application for registering [Commands] and notifying [Observers]
  • - *
- */ -class Facade implements IFacade -{ - /** - * Constructor. - * - *

This [IFacade] implementation is a Singleton, so you should not call the constructor - * directly, but instead call the static Singleton Factory method [Facade.getInstance()]

- */ - private function new() - { - instance = this; - initializeFacade(); - } - - /** - * Initialize the Singleton [Facade] instance. - * - *

Called automatically by the constructor. Override in your - * subclass to do any subclass specific initializations. Be - * sure to call [super.initializeFacade()], though.

- */ - private function initializeFacade(): Void - { - initializeModel(); - initializeController(); - initializeView(); - } - - /** - * Facade Singleton Factory method - */ - public static function getInstance(): IFacade - { - if ( instance == null ) instance = new Facade(); - return instance; - } - - /** - * Initialize the [Controller]. - * - *

Called by the [initializeFacade] method. Override this method in your subclass of [Facade] - * if one or both of the following are true:

- *
    - *
  • You wish to initialize a different [IController].
  • - *
  • You have [Commands] to register with the [Controller] at startup.
  • - *
- *

If you don't want to initialize a different [IController], - * call [super.initializeController()] at the beginning of your - * method, then register [Command]s.

- */ - private function initializeController(): Void - { - if ( controller != null ) return; - controller = Controller.getInstance(); - } - - /** - * Initialize the [Model]. - * - *

Called by the [initializeFacade] method. Override this method in your subclass of [Facade] - * if one or both of the following are true:

- *
    - *
  • You wish to initialize a different [IModel].
  • - *
  • You have [Proxy]s to register with the Model that do not - * retrieve a reference to the Facade at construction time.]
  • - *
- * - *

If you don't want to initialize a different [IModel], - * call [super.initializeModel()] at the beginning of your - * method, then register [Proxy]s. - * Note: This method is rarely overridden; in practice you are more - * likely to use a [Command] to create and register [Proxy]s - * with the [Model], since [Proxy]s with mutable data will likely - * need to send [INotification]s and thus will likely want to fetch a reference to - * the [Facade] during their construction. - *

- */ - private function initializeModel(): Void - { - if ( model != null ) return; - model = Model.getInstance(); - } - - /** - * Initialize the [View]. - * - *

Called by the [initializeFacade] method. - * Override this method in your subclass of [Facade] - * if one or both of the following are true:

- *
    - *
  • You wish to initialize a different [IView].
  • - *
  • You have [Observers] to register with the [View]
  • - *
- * If you don't want to initialize a different [IView], - * call [super.initializeView()] at the beginning of your method, then register [IMediator] instances. - *

Note: This method is rarely overridden; in practice you are more - * likely to use a [Command] to create and register [Mediator]s - * with the [View], since [IMediator] instances will need to send - * [INotification]s and thus will likely want to fetch a reference - * to the [Facade] during their construction.

- */ - private function initializeView(): Void - { - if ( view != null ) return; - view = View.getInstance(); - } - - /** - * Register an [ICommand] with the [Controller] by [Notification] name. - */ - public function registerCommand( notificationName: String, commandClassRef: Class ): Void - { - controller.registerCommand( notificationName, commandClassRef ); - } - - /** - * Remove a previously registered [ICommand] to [INotification] mapping from the [Controller]. - */ - public function removeCommand( notificationName: String ): Void - { - controller.removeCommand( notificationName ); - } - - /** - * Check if a [Command] is registered for a given [Notification] - */ - public function hasCommand( notificationName: String ): Bool - { - return controller.hasCommand( notificationName ); - } - - /** - * Register an [IProxy] with the [Model] by name. - */ - public function registerProxy( proxy: IProxy ): Void - { - model.registerProxy ( proxy ); - } - - /** - * Retrieve an [IProxy] from the [Model] by name. - */ - public function retrieveProxy( proxyName: String ): IProxy - { - return model.retrieveProxy( proxyName ); - } - - /** - * Remove an [IProxy] from the [Model] by name. - */ - public function removeProxy( proxyName: String ): IProxy - { - var proxy: IProxy = null; - if ( model != null ) proxy = model.removeProxy( proxyName ); - return proxy; - } - - /** - * Check if a [Proxy] is registered - */ - public function hasProxy( proxyName: String ): Bool - { - return model.hasProxy( proxyName ); - } - - /** - * Register a [IMediator] with the [View]. - */ - public function registerMediator( mediator: IMediator ): Void - { - if ( view != null ) view.registerMediator( mediator ); - } - - /** - * Retrieve an [IMediator] from the [View]. - */ - public function retrieveMediator( mediatorName: String ): IMediator - { - return view.retrieveMediator( mediatorName ); - } - - /** - * Remove an [IMediator] from the [View]. - */ - public function removeMediator( mediatorName: String ): IMediator - { - var mediator: IMediator = null; - if ( view != null ) mediator = view.removeMediator( mediatorName ); - return mediator; - } - - /** - * Check if a [Mediator] is registered or not - */ - public function hasMediator( mediatorName: String ): Bool - { - return view.hasMediator( mediatorName ); - } - - /** - * Create and send an [INotification]. - * - *

Keeps us from having to construct new notification - * instances in our implementation code. - */ - public function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void - { - notifyObservers( new Notification( notificationName, body, type ) ); - } - - /** - * Notify [Observer]s. - */ - public function notifyObservers( notification: INotification ): Void - { - if ( view != null ) view.notifyObservers( notification ); - } - - // Private references to Model, View and Controller - private var controller: IController; - private var model: IModel; - private var view: IView; - - // The Singleton Facade instance. - private static var instance: IFacade; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/mediator/Mediator.hx b/src/org/puremvc/haxe/patterns/mediator/Mediator.hx deleted file mode 100644 index e09b9c2..0000000 --- a/src/org/puremvc/haxe/patterns/mediator/Mediator.hx +++ /dev/null @@ -1,105 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.mediator; - -import org.puremvc.haxe.interfaces.INotification; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.interfaces.IMediator; -import org.puremvc.haxe.patterns.observer.Notifier; - -/** - * A base [IMediator] implementation. - */ -class Mediator extends Notifier implements IMediator -{ - - /** - * The name of the [Mediator]. - * - *

Typically, a [Mediator] will be written to serve - * one specific control or group controls and so, - * will not have a need to be dynamically named.

- */ - public static var NAME: String = 'Mediator'; - - /** - * Constructor. - */ - public function new( ?mediatorName: String, ?viewComponent: Dynamic ) - { - super(); - this.mediatorName = if( mediatorName != null ) mediatorName else NAME; - if( viewComponent != null ) - this.viewComponent = viewComponent; - } - - /** - * Get the name of the [Mediator]. - *

Override in subclass!

- */ - public function getMediatorName(): String - { - return mediatorName; - } - - /** - * Set the [IMediator]'s view component. - */ - public function setViewComponent( viewComponent: Dynamic ): Void - { - this.viewComponent = viewComponent; - } - - /** - * Get the [Mediator]'s view component. - */ - public function getViewComponent(): Dynamic - { - return viewComponent; - } - - /** - * List the [INotification] names this - * [Mediator] is interested in being notified of. - */ - public function listNotificationInterests(): Array - { - return []; - } - - /** - * Handle [INotification]s. - * - *

Typically this will be handled in a switch statement, - * with one 'case' entry per [INotification] - * the [Mediator] is interested in. - */ - public function handleNotification( notification: INotification ): Void - { - - } - - /** - * Called by the View when the Mediator is registered - */ - public function onRegister(): Void - { - } - - /** - * Called by the View when the Mediator is removed - */ - public function onRemove( ): Void - { - - } - - // the mediator name - private var mediatorName: String; - - // The view component - private var viewComponent: Dynamic; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/observer/Notification.hx b/src/org/puremvc/haxe/patterns/observer/Notification.hx deleted file mode 100644 index 8836202..0000000 --- a/src/org/puremvc/haxe/patterns/observer/Notification.hx +++ /dev/null @@ -1,109 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.observer; - -import org.puremvc.haxe.interfaces.INotification; - -/** - * A base [INotification] implementation. - * - *

PureMVC does not rely upon underlying event models such - * as the one provided with Flash.

- * - *

The Observer Pattern as implemented within PureMVC exists - * to support event-driven communication between the - * application and the actors of the MVC triad.

- * - *

Notifications are not meant to be a replacement for Events. - * Generally, [IMediator] implementors place event listeners on their view components, which they - * then handle in the usual way. This may lead to the broadcast of [Notification]s to - * trigger [ICommand]s or to communicate with other [IMediators]. [IProxy] and [ICommand] - * instances communicate with each other and [IMediator]s by broadcasting [INotification]s.

- * - *

A key difference between Flash [Event]s and PureMVC - * [Notification]s is that [Event]s follow the - * 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy - * until some parent component handles the [Event], while - * PureMVC [Notification]s follow a 'Publish/Subscribe' - * pattern. PureMVC classes need not be related to each other in a - * parent/child relationship in order to communicate with one another - * using [Notification]s. - */ -class Notification implements INotification -{ - /** - * Constructor. - */ - public function new( name: String, ?body: Dynamic, ?type: String ) - { - this.name = name; - if ( body != null ) - this.body = body; - if ( type != null ) - this.type = type; - } - - /** - * Get the name of the [Notification] instance. - */ - public function getName(): String - { - return name; - } - - /** - * Set the body of the [Notification] instance. - */ - public function setBody( body: Dynamic ): Void - { - this.body = body; - } - - /** - * Get the body of the [Notification] instance. - */ - public function getBody(): Dynamic - { - return body; - } - - /** - * Set the type of the [Notification] instance. - */ - public function setType( type: String ): Void - { - this.type = type; - } - - /** - * Get the type of the [Notification] instance. - */ - public function getType(): String - { - return type; - } - - /** - * Get the string representation of the [Notification] instance. - */ - public function toString(): String - { - var msg: String = "Notification Name: " + getName(); - msg += "\nBody:" + if( body == null ) "null" else body.toString(); - msg += "\nType:" + if( type == null ) "null" else type; - return msg; - } - - // the name of the notification instance - private var name : String; - - // the type of the notification instance - private var type : String; - - // the body of the notification instance - private var body : Dynamic; - -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/observer/Notifier.hx b/src/org/puremvc/haxe/patterns/observer/Notifier.hx deleted file mode 100644 index 5311fba..0000000 --- a/src/org/puremvc/haxe/patterns/observer/Notifier.hx +++ /dev/null @@ -1,50 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.observer; - -import org.puremvc.haxe.interfaces.IFacade; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.patterns.observer.Notification; -import org.puremvc.haxe.patterns.facade.Facade; - -/** - * A Base [INotifier] implementation. - * - *

[MacroCommand, Command, Mediator] and [Proxy] - * all have a need to send [Notifications].

- * - *

The [INotifier] interface provides a common method called - * [sendNotification] that relieves implementation code of - * the necessity to actually construct [Notifications].

- * - *

The [Notifier] class, which all of the above mentioned classes - * extend, provides an initialized reference to the [Facade] - * Singleton, which is required for the convienience method - * for sending [Notifications], but also eases implementation as these - * classes have frequent [Facade] interactions and usually require - * access to the facade anyway.

- */ -class Notifier implements INotifier -{ - public function new() - { - facade = Facade.getInstance(); - } - - /** - * Send an [INotification]s. - * - *

Keeps us from having to construct new notification - * instances in our implementation code.

- */ - public function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void - { - facade.sendNotification( notificationName, body, type ); - } - - // Local reference to the Facade Singleton - private var facade: IFacade; -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/observer/Observer.hx b/src/org/puremvc/haxe/patterns/observer/Observer.hx deleted file mode 100644 index fb822ad..0000000 --- a/src/org/puremvc/haxe/patterns/observer/Observer.hx +++ /dev/null @@ -1,93 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.observer; - -import org.puremvc.haxe.interfaces.IObserver; -import org.puremvc.haxe.interfaces.INotification; - -/** - * A base [IObserver] implementation. - * - *

An [Observer] is an object that encapsulates information - * about an interested object with a method that should - * be called when a particular [INotification] is broadcast.

- * - *

In PureMVC, the [Observer] class assumes these responsibilities:

- *
    - *
  • Encapsulate the notification (callback) method of the interested object.
  • - *
  • Encapsulate the notification context (this) of the interested object.
  • - *
  • Provide methods for setting the notification method and context.
  • - *
  • Provide a method for notifying the interested object.
  • - *
- */ -class Observer implements IObserver -{ - - private var notify: Dynamic -> Void; - private var context: Dynamic; - - /** - * Constructor. - * - *

The notification method on the interested object should take - * one parameter of type [INotification]

- */ - public function new( notifyMethod: Dynamic -> Void, notifyContext: Dynamic ): Void - { - setNotifyMethod( notifyMethod ); - setNotifyContext( notifyContext ); - } - - /** - * Set the notification method. - * - *

The notification method should take one parameter of type [INotification].

- */ - public function setNotifyMethod( notifyMethod: Dynamic -> Void ): Void - { - notify = notifyMethod; - } - - /** - * Set the notification context. - */ - public function setNotifyContext( notifyContext: Dynamic ): Void - { - context = notifyContext; - } - - /** - * Get the notification method. - */ - private function getNotifyMethod(): Dynamic -> Void - { - return notify; - } - - /** - * Get the notification context. - */ - private function getNotifyContext(): Dynamic - { - return context; - } - - /** - * Notify the interested object. - */ - public function notifyObserver( notification: INotification ): Void - { - getNotifyMethod()( notification ); - } - - /** - * Compare an object to the notification context. - */ - public function compareNotifyContext( object: Dynamic ): Bool - { - return object == this.context; - } -} \ No newline at end of file diff --git a/src/org/puremvc/haxe/patterns/proxy/Proxy.hx b/src/org/puremvc/haxe/patterns/proxy/Proxy.hx deleted file mode 100644 index 3da58ce..0000000 --- a/src/org/puremvc/haxe/patterns/proxy/Proxy.hx +++ /dev/null @@ -1,88 +0,0 @@ -/* - PureMVC haXe Port by Marco Secchi - PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. - Your reuse is governed by the Creative Commons Attribution 3.0 License - */ -package org.puremvc.haxe.patterns.proxy; - -import org.puremvc.haxe.interfaces.IProxy; -import org.puremvc.haxe.interfaces.INotifier; -import org.puremvc.haxe.patterns.observer.Notifier; - -/** - * A base [IProxy] implementation. - * - *

In PureMVC, [Proxy] classes are used to manage parts of the - * application's data model.

- * - *

A [Proxy] might simply manage a reference to a local data object, - * in which case interacting with it might involve setting and - * getting of its data in synchronous fashion.

- * - *

[Proxy] classes are also used to encapsulate the application's - * interaction with remote services to save or retrieve data, in which case, - * we adopt an asyncronous idiom; setting data (or calling a method) on the - * [Proxy] and listening for a [Notification] to be sent - * when the [Proxy] has retrieved the data from the service.

- */ -class Proxy extends Notifier implements IProxy -{ - - public static var NAME: String = 'Proxy'; - - /** - * Constructor - */ - public function new( ?proxyName: String, ?data: Dynamic ) - { - super(); - this.proxyName = if( proxyName != null ) proxyName else NAME; - if ( data != null ) setData( data ); - } - - /** - * Get the proxy name - */ - public function getProxyName(): String - { - return proxyName; - } - - /** - * Set the data object - */ - public function setData( data: Dynamic ): Void - { - this.data = data; - } - - /** - * Get the data object - */ - public function getData(): Dynamic - { - return data; - } - - /** - * Called by the [Model] when the [Proxy] is registered - */ - public function onRegister(): Void - { - - } - - /** - * Called by the [Model] when the [Proxy] is removed - */ - public function onRemove(): Void - { - - } - - // the proxy name - private var proxyName: String; - - // the data object - private var data: Dynamic; -} \ No newline at end of file