├── LICENSE ├── README.md ├── VERSION ├── bin ├── PureMVC_Haxe_MC_1_2_fl6.swf ├── PureMVC_Haxe_MC_1_2_fl7.swf ├── PureMVC_Haxe_MC_1_2_fl8.swf ├── PureMVC_Haxe_MC_1_2_fl9.swf └── PureMVC_Haxe_MC_1_2_js.js ├── build.hxml ├── docs ├── all.n ├── content │ ├── Array.html │ ├── ArrayAccess.html │ ├── Bool.html │ ├── Class.html │ ├── Dynamic.html │ ├── Enum.html │ ├── EnumValue.html │ ├── Hash.html │ ├── Int.html │ ├── IntIter.html │ ├── Iterable.html │ ├── Iterator.html │ ├── List.html │ ├── Math.html │ ├── Null.html │ ├── Reflect.html │ ├── Std.html │ ├── String.html │ ├── StringBuf.html │ ├── Type.html │ ├── ValueType.html │ ├── Void.html │ └── org │ │ └── puremvc │ │ └── haxe │ │ └── multicore │ │ ├── core │ │ ├── Controller.html │ │ ├── Model.html │ │ └── View.html │ │ ├── interfaces │ │ ├── ICommand.html │ │ ├── IController.html │ │ ├── IFacade.html │ │ ├── IMediator.html │ │ ├── IModel.html │ │ ├── INotification.html │ │ ├── INotifier.html │ │ ├── IObserver.html │ │ ├── IProxy.html │ │ └── IView.html │ │ └── patterns │ │ ├── command │ │ ├── MacroCommand.html │ │ └── SimpleCommand.html │ │ ├── facade │ │ └── Facade.html │ │ ├── mediator │ │ └── Mediator.html │ │ ├── observer │ │ ├── Notification.html │ │ ├── Notifier.html │ │ └── Observer.html │ │ └── proxy │ │ └── Proxy.html ├── index.html ├── puremvc_docs.xml └── template.xml └── src └── org └── puremvc └── haxe └── multicore ├── ImportAll.hx ├── core ├── Controller.hx ├── Model.hx └── View.hx ├── interfaces ├── ICommand.hx ├── IController.hx ├── IFacade.hx ├── IMediator.hx ├── IModel.hx ├── INotification.hx ├── INotifier.hx ├── IObserver.hx ├── IProxy.hx └── IView.hx └── patterns ├── command ├── MacroCommand.hx └── SimpleCommand.hx ├── facade └── Facade.hx ├── mediator └── Mediator.hx ├── observer ├── Notification.hx ├── Notifier.hx └── Observer.hx └── proxy └── Proxy.hx /LICENSE: -------------------------------------------------------------------------------- 1 | * PureMVC MultiCore Framework for Haxe (Ported) - Copyright © 2008-2009 Marco Secchi 2 | * PureMVC - Copyright © 2006-2012 Futurescale, Inc. 3 | * All rights reserved. 4 | 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | * Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## [PureMVC](http://puremvc.github.com/) Haxe MultiCore Framework 2 | PureMVC is a lightweight framework for creating applications based upon the classic [Model-View-Controller](http://en.wikipedia.org/wiki/Model-view-controller) design meta-pattern. This is a Haxe port of the [AS3 reference implementation of the MultiCore Version](https://github.com/PureMVC/puremvc-as3-multicore-framework/wiki). It supports [modular programming](http://en.wikipedia.org/wiki/Modular_programming) through the use of [Multiton](http://en.wikipedia.org/wiki/Multiton) Core actors instead of the [Singleton](http://en.wikipedia.org/wiki/Singleton_pattern)s used in the [Standard Version](https://github.com/PureMVC/puremvc-haxe-standard-framework/wiki). 3 | 4 | * [API Docs](http://puremvc.org/pages/docs/Haxe/multicore/docs) 5 | * [Unit Tests](https://github.com/PureMVC/puremvc-haxe-multicore-unittests/wiki) 6 | * [Discussion](http://forums.puremvc.org/index.php?board=57.0) 7 | * [Overview Presentation](http://puremvc.tv/#P002) 8 | 9 | ## Demos 10 | * [Stop Watch](https://github.com/PureMVC/puremvc-haxe-demo-xinf-stopwatch/wiki) 11 | 12 | ## Utilities 13 | * [Async Command](https://github.com/PureMVC/puremvc-haxe-util-asynccommand/wiki) 14 | * [Async Stub](https://github.com/PureMVC/puremvc-haxe-util-async-stub/wiki) 15 | * [Pipes](https://github.com/PureMVC/puremvc-haxe-util-pipes/wiki) 16 | * [State Machine](https://github.com/PureMVC/puremvc-haxe-util-statemachine/wiki) 17 | * [Undo](https://github.com/PureMVC/puremvc-haxe-util-undo/wiki) 18 | 19 | ## Status 20 | Production - [Version 1.4](https://github.com/PureMVC/puremvc-haxe-multicore-framework/blob/master/VERSION) 21 | 22 | ## Platforms / Technologies 23 | * [haxe](http://en.wikipedia.org/wiki/haxe) 24 | 25 | ## License 26 | * PureMVC MultiCore Framework for Haxe (Ported) - Copyright © 2008-2009 Marco Secchi 27 | * PureMVC - Copyright © 2006-2012 Futurescale, Inc. 28 | * All rights reserved. 29 | 30 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 31 | 32 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 33 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 34 | * Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 35 | 36 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | PureMVC MultiCore Framework for Haxe (Ported) - Copyright © 2008-2013 Marco Secchi 2 | -------------------------------------------------------------------------- 3 | Release Date: 4/20/13 4 | Platform: haXe - JavaScript, Flash 6, 7, 8, 9, Neko VM 5 | Version: 1 6 | Revision: 4 7 | Author: Marco Secchi 8 | -------------------------------------------------------------------------- 9 | 1.4 Facade.instanceMap available by default otherwise constructor call fails! 10 | 11 | 1.3 Haxe 3 support added by zjnue 12 | 13 | 1.2 Libraries now include version number. - CLH 14 | 15 | 1.1 haXe 2.0 compatibility. This version is no longer compatible with 16 | older versions of haXe. - MS 17 | 18 | 1.0 First official release on PureMVC multicore. - MS 19 | -------------------------------------------------------------------------------- /bin/PureMVC_Haxe_MC_1_2_fl6.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PureMVC/puremvc-haxe-multicore-framework/8ae97e3e3ab977e4e9d79eaa9a9c4fd24f602169/bin/PureMVC_Haxe_MC_1_2_fl6.swf -------------------------------------------------------------------------------- /bin/PureMVC_Haxe_MC_1_2_fl7.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PureMVC/puremvc-haxe-multicore-framework/8ae97e3e3ab977e4e9d79eaa9a9c4fd24f602169/bin/PureMVC_Haxe_MC_1_2_fl7.swf -------------------------------------------------------------------------------- /bin/PureMVC_Haxe_MC_1_2_fl8.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PureMVC/puremvc-haxe-multicore-framework/8ae97e3e3ab977e4e9d79eaa9a9c4fd24f602169/bin/PureMVC_Haxe_MC_1_2_fl8.swf -------------------------------------------------------------------------------- /bin/PureMVC_Haxe_MC_1_2_fl9.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PureMVC/puremvc-haxe-multicore-framework/8ae97e3e3ab977e4e9d79eaa9a9c4fd24f602169/bin/PureMVC_Haxe_MC_1_2_fl9.swf -------------------------------------------------------------------------------- /build.hxml: -------------------------------------------------------------------------------- 1 | # PureMVC haXe Port by Marco Secchi 2 | # PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 3 | # Your reuse is governed by the Creative Commons Attribution 3.0 License 4 | 5 | # build flash9 library 6 | -cp src 7 | -swf bin/PureMVC_Haxe_MC_1_2_fl9.swf 8 | -swf-version 9 9 | org.puremvc.haxe.multicore.ImportAll 10 | 11 | # build flash8 library 12 | --next 13 | -cp src 14 | -swf bin/PureMVC_Haxe_MC_1_2_fl8.swf 15 | -swf-version 8 16 | org.puremvc.haxe.multicore.ImportAll 17 | 18 | # build flash7 library 19 | --next 20 | -cp src 21 | -swf bin/PureMVC_Haxe_MC_1_2_fl7.swf 22 | -swf-version 7 23 | org.puremvc.haxe.multicore.ImportAll 24 | 25 | # build flash6 library 26 | --next 27 | -cp src 28 | -swf bin/PureMVC_Haxe_MC_1_2_fl6.swf 29 | -swf-version 6 30 | org.puremvc.haxe.multicore.ImportAll 31 | 32 | # build javascript library 33 | --next 34 | -cp src 35 | -js bin/PureMVC_Haxe_MC_1_2_js.js 36 | org.puremvc.haxe.multicore.ImportAll 37 | 38 | # build docs 39 | # use the following command-line action to generate docs: 40 | # haxedoc puremvc_docs.xml -f Array -f Bool -f org -f Class -f Dynamic -f Enum -f float -f Hash -f Int -f Iter -f List -f Math -f Null -f Reflect -f Std -f String -f Type -f Void -f Value 41 | --next 42 | -cp src 43 | -neko docs/all.n 44 | -xml docs/puremvc_docs.xml 45 | org.puremvc.haxe.multicore.ImportAll 46 | -cmd cd docs 47 | -cmd haxedoc puremvc_docs.xml -f Array -f Bool -f org -f Class -f Dynamic -f Enum -f float -f Hash -f Int -f Iter -f List -f Math -f Null -f Reflect -f Std -f String -f Type -f Void -f Value 48 | -------------------------------------------------------------------------------- /docs/all.n: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PureMVC/puremvc-haxe-multicore-framework/8ae97e3e3ab977e4e9d79eaa9a9c4fd24f602169/docs/all.n -------------------------------------------------------------------------------- /docs/content/ArrayAccess.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
extern interface ArrayAccess<T>
import StdTypes
ArrayAccess is used to indicate a class that can be accessed using brackets. 117 | The type parameter represent the type of the elements stored.
Back | Index 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/content/Bool.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Bool
import StdTypes
The standard Boolean type is represented as an enum with two choices.
Back | Index 117 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/content/Class.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Class<T>

An abstract type that represents a Class.

117 |

See Type for the haXe Reflection API.

Back | Index 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/content/Dynamic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Dynamic<T>
import StdTypes
Dynamic is an internal compiler type which has special behavior. 117 | See the haXe language reference for more informations.
Back | Index 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/content/Enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Enum<T>

An abstract type that represents an Enum type.

117 |

The corresponding enum instance type is EnumValue.

118 |

See Type for the haXe Reflection API.

Back | Index 119 | 120 |
121 | 122 | 123 | -------------------------------------------------------------------------------- /docs/content/EnumValue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract EnumValue
An abstract type that represents any enum value. 117 | See Type for the haXe Reflection API.
Back | Index 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/content/Hash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | haXe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for haXe: API Documentation
115 | 116 | Back | Index
class Hash<T>
117 | Hashtable over a set of elements, using String as keys. 118 | Other kind of keys are not possible on all platforms since they 119 | can't always be implemented efficiently. 120 |
function new() : Void
121 | Creates a new empty hashtable. 122 |
function exists(key : String) : Bool
123 | Tells if a value exists for the given key. 124 | In particular, it's useful to tells if a key has 125 | a null value versus no value. 126 |
function get(key : String) : Null<T>
127 | Get a value for the given key. 128 |
function iterator() : Iterator<T>
129 | Returns an iterator of all values in the hashtable. 130 |
function keys() : Iterator<String>
131 | Returns an iterator of all keys in the hashtable. 132 |
function remove(key : String) : Bool
133 | Removes a hashtable entry. Returns true if 134 | there was such entry. 135 |
function set(key : String, value : T) : Void
136 | Set a value for the given key. 137 |
function toString() : String
138 | Returns an displayable representation of the hashtable content. 139 |
Back | Index 140 | 141 |
142 | 143 | 144 | -------------------------------------------------------------------------------- /docs/content/Int.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Int
import StdTypes
The standard Int type. Its precision depends on the platform.
Back | Index 117 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/content/IntIter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | haXe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for haXe: API Documentation
115 | 116 | Back | Index
class IntIter
117 | Integer iterator. Used for interval implementation. 118 |
function new(min : Int, max : Int) : Void
119 | Iterate from min (inclusive) to max (exclusive). 120 | If max <= min, the iterator will not act as a countdown. 121 |
function hasNext() : Bool
function next() : Int
Back | Index 122 | 123 |
124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/content/Iterable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
typedef Iterable<T>
import StdTypes
An Iterable is a data structure which has an iterator() method. 117 | See Lambda for generic functions on iterable structures.
Back | Index 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /docs/content/Iterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
typedef Iterator<T>
import StdTypes

An Iterator is a structure that permits iteration over elements of type T.

117 |

Any class with matching hasNext and next fields is considered an Iterator 118 | and can then be used e.g. in for-loops. This makes it easy to implement 119 | custom iterators.

Back | Index 120 | 121 |
122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/content/List.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class List<T>
A linked-list of elements. The list is composed of two-elements arrays 117 | that are chained together. It's optimized so that adding or removing an 118 | element doesn't imply to copy the whole array content everytime.
var length(default,null) : Int
The number of elements in this list.
function new() : Void
Creates a new empty list.
function add(item : T) : Void
function isEmpty() : Bool
function iterator() : Iterator<T>
function pop() : Null<T>
function remove(v : T) : Bool
Back | Index 119 | 120 |
121 | 122 | 123 | -------------------------------------------------------------------------------- /docs/content/Null.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
typedef Null<T>
import StdTypes
Null can be useful in two cases. In order to document some methods 117 | that accepts or can return a null value, or for the Flash9 compiler and AS3 118 | generator to distinguish between base values that can be null and others that 119 | can't.
= T
Back | Index 120 | 121 |
122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/content/Reflect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | haXe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for haXe: API Documentation
115 | 116 | Back | Index
class Reflect
117 | The Reflect API is a way to manipulate values dynamicly through an 118 | abstract interface in an untyped manner. Use with care. 119 |
static function callMethod(o : Dynamic, func : Dynamic, args : Array<Dynamic>) : Dynamic
120 | Call a method with the given object and arguments. 121 |
static function compare<T>(a : T, b : T) : Int
122 | Generic comparison function, does not work for methods, see compareMethods 123 |
static function compareMethods(f1 : Dynamic, f2 : Dynamic) : Bool
124 | Compare two methods closures. Returns true if it's the same method of the same instance. 125 | Does not work on Neko platform. 126 |
static function copy<T>(o : T) : T
127 | Make a copy of the fields of an object. 128 |
static function deleteField(o : Dynamic, f : String) : Bool
129 | Delete an object field. 130 |
static function field(o : Dynamic, field : String) : Dynamic
131 | Returns the field of an object, or null if o is not an object or doesn't have this field. 132 |
static function fields(o : Dynamic) : Array<String>
133 | Returns the list of fields of an object, excluding its prototype (class methods). 134 |
static function hasField(o : Dynamic, field : String) : Bool
135 | Tells if an object has a field set. This doesn't take into account the object prototype (class methods). 136 |
static function isFunction(f : Dynamic) : Bool
137 | Tells if a value is a function or not. 138 |
static function isObject(v : Dynamic) : Bool

Tells if a value is an object or not.

139 |

static function makeVarArgs(f : Array<Dynamic> -> Dynamic) : Dynamic
140 | Transform a function taking an array of arguments into a function that can 141 | be called with any number of arguments. 142 |
static function setField(o : Dynamic, field : String, value : Dynamic) : Void
143 | Set an object field value. 144 |
Back | Index 145 | 146 |
147 | 148 | 149 | -------------------------------------------------------------------------------- /docs/content/Std.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class Std
The Std class provides standard methods for manipulating basic types.
static function string(s : Dynamic) : String

Converts any value to a String.

117 |

If s is of String, Int, Float or Bool, its value is returned.

118 |

If s is an instance of a class and that class or one of its parent classes has 119 | a toString() method, that method is called. If no such method is present, the result 120 | is unspecified.

121 |

If s is an enum constructor without argument, the constructor's name is returned. If 122 | arguments exists, the constructor's name followed by the String representations of 123 | the arguments is returned.

124 |

If s is a structure, the field names along with their values are returned. The field order 125 | and the operator separating field names and values are unspecified.

126 |

If s is null, "null" is returned.

Back | Index 127 | 128 |
129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/content/StringBuf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class StringBuf

A String buffer is an efficient way to build a big string by appending small 117 | elements together.

118 |

Its cross-platform implementation uses String concatenation internally, but 119 | StringBuf may be optimized for different targets.

120 |

Unlike String, an instance of StringBuf is not immutable in the sense that 121 | it can be passed as argument to functions which modify it by appending more 122 | values. However, the internal buffer cannot be modified.

function new() : Void

Creates a new StringBuf instance.

123 |

This may involve initialization of the internal buffer.

Back | Index 124 | 125 |
126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/content/Type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class Type

The haxe Reflection API allows retrieval of type information at runtime.

117 |

This class complements the more lightweight Reflect class, with a focus on 118 | class and enum instances.

static function createInstance<T>(cl : Class<T>, args : Array<Dynamic>) : T

Creates an instance of class cl, using args as arguments to the 119 | class constructor.

120 |

This function guarantees that the class constructor is called.

121 |

Default values of constructors arguments are not guaranteed to be 122 | taken into account.

123 |

If cl or args are null, or if the number of elements in args does 124 | not match the expected number of constructor arguments, or if any 125 | argument has an invalid type, or if cl has no own constructor, the 126 | result is unspecified.

127 |

In particular, default values of constructor arguments are not 128 | guaranteed to be taken into account.

Back | Index 129 | 130 |
131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/content/ValueType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | haXe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for haXe: API Documentation
115 | 116 | Back | Index
enum ValueType
import Type
117 | The diffent possible runtime types of a value. 118 | See Type for the haXe Reflection API. 119 |
TUnknown
TObject
TNull
TInt
TFunction
TFloat
TEnum(e : Enum)
TClass(c : Class<Dynamic>)
TBool
Back | Index 120 | 121 |
122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/content/Void.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
abstract Void
import StdTypes
The standard Void type. Only null values can be of the type Void.
Back | Index 117 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/core/Controller.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.core.Controller

A Multiton IController implementation.

117 |

In PureMVC, the Controller class follows the 118 | 'Command and Controller' strategy, and assumes these responsibilities:

119 |
    120 |
  • Remembering which ICommands are intended to handle which INotifications.
  • 121 |
  • Registering itself as an IObserver with the View for each INotification 122 | that it has an ICommand mapping for.
  • 123 |
  • Creating a new instance of the proper ICommand to handle a given INotification 124 | when notified by the View.
  • 125 |
  • Calling the ICommand's execute method, passing in the INotification.
  • 126 |

127 |

Your application must register ICommands with the Controller. 128 | The simplest way is to subclass Facade, 129 | and use its initializeController method to add your registrations.

function executeCommand(note : org.puremvc.haxe.multicore.interfaces.INotification) : Void
function hasCommand(notificationName : String) : Bool
function registerCommand(notificationName : String, commandClassRef : Class<org.puremvc.haxe.multicore.interfaces.ICommand>) : Void
function removeCommand(notificationName : String) : Void
function removeController(key : String) : Void
static function getInstance(key : String) : org.puremvc.haxe.multicore.interfaces.IController
Back | Index 130 | 131 |
132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/core/Model.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.core.Model

A Singleton IModel implementation.

117 |

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

118 |

The Model assumes these responsibilities:

119 |
    120 |
  • Maintain a cache of IProxy instances.
  • 121 |
  • Provide methods for registering, retrieving, and removing IProxy instances.
  • 122 |

123 |

Your application must register IProxy instances with the Model. Typically, you use an 124 | ICommand to create and register IProxy instances once the Facade has initialized the Core 125 | actors.

function hasProxy(proxyName : String) : Bool
function registerProxy(proxy : org.puremvc.haxe.multicore.interfaces.IProxy) : Void
function removeModel(key : String) : Void
function removeProxy(proxyName : String) : org.puremvc.haxe.multicore.interfaces.IProxy
function retrieveProxy(proxyName : String) : org.puremvc.haxe.multicore.interfaces.IProxy
static function getInstance(key : String) : org.puremvc.haxe.multicore.interfaces.IModel
Back | Index 126 | 127 |
128 | 129 | 130 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/core/View.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.core.View

A Multiton IView implementation.

117 |

In PureMVC, the View class assumes these responsibilities:

118 |
    119 |
  • Maintain a cache of IMediator instances.
  • 120 |
  • Provide methods for registering, retrieving, and removing IMediators.
  • 121 |
  • Notifiying IMediators when they are registered or removed.
  • 122 |
  • Managing the observer lists for each INotification in the application.
  • 123 |
  • Providing a method for attaching IObservers to an INotification's observer list.
  • 124 |
  • Providing a method for broadcasting an INotification.
  • 125 |
  • Notifying the IObservers of a given INotification when it broadcast.
  • 126 |

function new(key : String) : Void

Constructor.

127 |

This IView implementation is a Multiton, 128 | so you should not call the constructor 129 | directly, but instead call the static Multiton 130 | Factory method View.getInstance( multitonKey )

function hasMediator(mediatorName : String) : Bool
function notifyObservers(notification : org.puremvc.haxe.multicore.interfaces.INotification) : Void
function registerMediator(mediator : org.puremvc.haxe.multicore.interfaces.IMediator) : Void
function registerObserver(notificationName : String, observer : org.puremvc.haxe.multicore.interfaces.IObserver) : Void
function removeMediator(mediatorName : String) : org.puremvc.haxe.multicore.interfaces.IMediator
function removeObserver(notificationName : String, notifyContext : Dynamic) : Void
function removeView(key : String) : Void
function retrieveMediator(mediatorName : String) : org.puremvc.haxe.multicore.interfaces.IMediator
static function getInstance(key : String) : org.puremvc.haxe.multicore.interfaces.IView
Back | Index 131 | 132 |
133 | 134 | 135 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/ICommand.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.ICommand
extends INotifier
The interface definition for a PureMVC Command.
function execute(notification : INotification) : Void
Execute the ICommand's logic to handle a given INotification.
Back | Index 117 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IController.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IController

The interface definition for a PureMVC Controller.

117 |

In PureMVC, an IController implementor 118 | follows the 'Command and Controller' strategy, and 119 | assumes these responsibilities:

120 |
    121 |
  • Remembering which ICommands 122 | are intended to handle which INotifications.
  • 123 |
  • Registering itself as an IObserver with 124 | the View for each INotification 125 | that it has an ICommand mapping for.
  • 126 |
  • Creating a new instance of the proper ICommand 127 | to handle a given INotification when notified by the View.
  • 128 |
  • Calling the ICommand's execute 129 | method, passing in the INotification.
  • 130 |

function executeCommand(notification : INotification) : Void
Execute the ICommand previously registered as the 131 | handler for INotifications with the given notification name.
function hasCommand(notificationName : String) : Bool
Check if a Command is registered for a given Notification
function registerCommand(notificationName : String, commandClassRef : Class<ICommand>) : Void
Register a particular ICommand class as the handler 132 | for a particular INotification.
function removeCommand(notificationName : String) : Void
Remove a previously registered ICommand to INotification mapping.
function removeController(key : String) : Void
Remove an IController instance
Back | Index 133 | 134 |
135 | 136 | 137 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IMediator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IMediator
extends INotifier

The interface definition for a PureMVC Mediator.

117 |

In PureMVC, IMediator implementors assume these responsibilities:

118 |
    119 |
  • Implement a common method which returns a list of all INotifications 120 | the IMediator has interest in.
  • 121 |
  • Implement a common notification (callback) method.
  • 122 |
123 |

Additionally, IMediators typically:

124 |
    125 |
  • Act as an intermediary between one or more view components such as text boxes or 126 | list controls, maintaining references and coordinating their behavior.
  • 127 |
  • In Flash-based apps, this is often the place where event listeners are 128 | added to view components, and their handlers implemented.
  • 129 |
  • Respond to and generate INotifications, interacting with of 130 | the rest of the PureMVC app.
  • 131 |
132 |

When an IMediator is registered with the IView, 133 | the IView will call the IMediator's 134 | listNotificationInterests method. The IMediator will 135 | return an Array of INotification names which 136 | it wishes to be notified about.

137 |

The IView will then create an Observer object 138 | encapsulating that IMediator's (handleNotification) method 139 | and register it as an Observer for each INotification name returned by 140 | listNotificationInterests.

function getMediatorName() : String
Get the IMediator instance name
function getViewComponent() : Dynamic
Get the IMediator's view component.
function handleNotification(notification : INotification) : Void
Handle an INotification.
function listNotificationInterests() : Array<String>
List INotification interests.
function onRegister() : Void
Called by the View when the Mediator is registered
function onRemove() : Void
Called by the View when the Mediator is removed
function setViewComponent(viewComponent : Dynamic) : Void
Set the IMediator's view component.
Back | Index 141 | 142 |
143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IModel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IModel

The interface definition for a PureMVC Model.

117 |

In PureMVC, IModel implementors provide 118 | access to IProxy objects by named lookup.

119 |

An IModel assumes these responsibilities:

120 |
    121 |
  • Maintain a cache of IProxy instances
  • 122 |
  • Provide methods for registering, retrieving, and removing IProxy instances
  • 123 |

function hasProxy(proxyName : String) : Bool
Check if a Proxy is registered
function registerProxy(proxy : IProxy) : Void
Register an IProxy instance with the Model.
function removeModel(key : String) : Void
Remove an IModel instance
function removeProxy(proxyName : String) : IProxy
Remove an IProxy instance from the Model.
function retrieveProxy(proxyName : String) : IProxy
Retrieve an IProxy instance from the Model.
Back | Index 124 | 125 |
126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/INotification.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.INotification

The interface definition for a PureMVC Notification.

117 |

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

119 |

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

122 |

Notifications are not meant to be a replacement for Events. 123 | Generally, IMediator implementors 124 | place event listeners on their view components, which they 125 | then handle in the usual way. This may lead to the broadcast of Notifications to 126 | trigger ICommands or to communicate with other IMediators. IProxy and ICommand 127 | instances communicate with each other and IMediators 128 | by broadcasting INotifications.

129 |

A key difference between Flash Events and PureMVC 130 | Notifications is that Events follow the 131 | 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy 132 | until some parent component handles the Event, while 133 | PureMVC Notifications follow a 'Publish/Subscribe' 134 | pattern. PureMVC classes need not be related to each other in a 135 | parent/child relationship in order to communicate with one another 136 | using Notifications.

function getBody() : Dynamic
Get the body of the INotification instance
function getName() : String
Get the name of the INotification instance. 137 | No setter, should be set by constructor only
function getType() : String
Get the type of the INotification instance
function setBody(body : Dynamic) : Void
Set the body of the INotification instance
function setType(type : String) : Void
Set the type of the INotification instance
function toString() : String
Get the string representation of the INotification instance
Back | Index 138 | 139 |
140 | 141 | 142 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/INotifier.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.INotifier

The interface definition for a PureMVC Notifier.

117 |

MacroCommand, Command, Mediator and Proxy 118 | all have a need to send Notifications.

119 |

The INotifier interface provides a common method called 120 | sendNotification that relieves implementation code of 121 | the necessity to actually construct Notifications.

122 |

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

function initializeNotifier(key : String) : Void

Initialize this INotifier instance.

128 |

This is how a Notifier gets its multitonKey. 129 | Calls to sendNotification or to access the 130 | facade will fail until after this method 131 | has been called.

function sendNotification(notificationName : String, ?body : Dynamic, ?type : String) : Void

Send a INotification.

132 |

Convenience method to prevent having to construct new 133 | notification instances in our implementation code.

Back | Index 134 | 135 |
136 | 137 | 138 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IObserver.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IObserver

The interface definition for a PureMVC Observer.

117 |

In PureMVC, IObserver implementors assume these responsibilities: 118 |

    119 |
  • Encapsulate the notification (callback) method of the interested object.
  • 120 |
  • Encapsulate the notification context (this) of the interested object.
  • 121 |
  • Provide methods for setting the interested object' notification method and context.
  • 122 |
  • Provide a method for notifying the interested object.
  • 123 |

124 |

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

126 |

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

129 |

An Observer is an object that encapsulates information 130 | about an interested object with a notification method that 131 | should be called when an INotification is broadcast. The Observer then 132 | acts as a proxy for notifying the interested object.

133 |

Observers can receive Notifications by having their 134 | notifyObserver method invoked, passing 135 | in an object implementing the INotification interface, such 136 | as a subclass of Notification.

function compareNotifyContext(object : Dynamic) : Bool
Compare the given object to the notificaiton context object.
function notifyObserver(notification : INotification) : Void
Notify the interested object.
function setNotifyContext(notifyContext : Dynamic) : Void
Set the notification context.
function setNotifyMethod(notifyMethod : Dynamic -> Void) : Void

Set the notification method.

137 |

The notification method should take one parameter of type INotification

Back | Index 138 | 139 |
140 | 141 | 142 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IProxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IProxy
extends INotifier

The interface definition for a PureMVC Proxy.

117 |

In PureMVC, IProxy implementors assume these responsibilities:

118 |
    119 |
  • Implement a common method which returns the name of the Proxy.
  • 120 |
121 |

Additionally, IProxys typically:

122 |
    123 |
  • Maintain references to one or more pieces of model data.
  • 124 |
  • Provide methods for manipulating that data.
  • 125 |
  • Generate INotifications when their model data changes.
  • 126 |
  • Expose their name as a public static var called NAME.
  • 127 |
  • Encapsulate interaction with local or remote services used to fetch and persist model data.
  • 128 |

function getData() : Dynamic
Get the data object
function getProxyName() : String
Get the Proxy name
function onRegister() : Void
Called by the Model when the Proxy is registered
function onRemove() : Void
Called by the Model when the Proxy is removed
function setData(data : Dynamic) : Void
Set the data object
Back | Index 129 | 130 |
131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/interfaces/IView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
interface org.puremvc.haxe.multicore.interfaces.IView

The interface definition for a PureMVC View.

117 |

In PureMVC, the View class assumes these responsibilities: 118 |

    119 |
  • Maintain a cache of IMediator instances.
  • 120 |
  • Provide methods for registering, retrieving, and removing IMediators.
  • 121 |
  • Managing the observer lists for each INotification in the application.
  • 122 |
  • Providing a method for attaching IObservers to an INotification's observer list.
  • 123 |
  • Providing a method for broadcasting an INotification.
  • 124 |
  • Notifying the IObservers of a given INotification when it broadcast.
  • 125 |

function hasMediator(mediatorName : String) : Bool
Check if a Mediator is registered or not
function notifyObservers(note : INotification) : Void

Notify the IObservers for a particular INotification.

126 |

All previously attached IObservers for this INotification's 127 | list are notified and are passed a reference to the INotification in 128 | the order in which they were registered.

function registerMediator(mediator : IMediator) : Void

Register an IMediator instance with the View.

129 |

Registers the IMediator so that it can be retrieved by name, 130 | and further interrogates the IMediator for its INotification interests.

131 |

If the IMediator returns any INotification 132 | names to be notified about, an Observer is created encapsulating 133 | the IMediator instance's handleNotification method 134 | and registering it as an Observer for all INotifications the 135 | IMediator is interested in.

function registerObserver(noteName : String, observer : IObserver) : Void
Register an IObserver to be notified of INotifications with a given name.
function removeMediator(mediatorName : String) : IMediator
Remove an IMediator from the View.
function removeObserver(notificationName : String, notifyContext : Dynamic) : Void
Remove a group of observers from the observer list for a given Notification name.
function removeView(key : String) : Void
Remove an IView instance
function retrieveMediator(mediatorName : String) : IMediator
Retrieve an IMediator from the View.
Back | Index 136 | 137 |
138 | 139 | 140 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/command/MacroCommand.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.command.MacroCommand

A base ICommand implementation that executes other ICommands.

117 |

A MacroCommand maintains an list of 118 | ICommand Class references called SubCommands.

119 |

When execute is called, the MacroCommand 120 | instantiates and calls execute on each of its SubCommands turn. 121 | Each SubCommand will be passed a reference to the original 122 | INotification that was passed to the MacroCommand's 123 | execute method.

124 |

Unlike SimpleCommand, your subclass 125 | should not override execute, but instead, should 126 | override the initializeMacroCommand method, 127 | calling addSubCommand once for each SubCommand 128 | to be executed.

function new() : Void

Constructor.

129 |

You should not need to define a constructor, 130 | instead, override the initializeMacroCommand 131 | method.

132 |

133 | If your subclass does define a constructor, be 134 | sure to call super().

function execute(notification : org.puremvc.haxe.multicore.interfaces.INotification) : Void
Back | Index 135 | 136 |
137 | 138 | 139 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/command/SimpleCommand.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.command.SimpleCommand

A base ICommand implementation.

117 |

Your subclass should override the execute 118 | method where your business logic will handle the INotification.

function new() : Void
function execute(notification : org.puremvc.haxe.multicore.interfaces.INotification) : Void

Fulfill the use-case initiated by the given INotification.

119 |

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

Back | Index 122 | 123 |
124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/mediator/Mediator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.mediator.Mediator
A base IMediator implementation.
function new(?mediatorName : String, ?viewComponent : Dynamic) : Void
Constructor.
function getMediatorName() : String
function getViewComponent() : Dynamic
function handleNotification(notification : org.puremvc.haxe.multicore.interfaces.INotification) : Void
function listNotificationInterests() : Array<String>
function onRegister() : Void
function onRemove() : Void
function setViewComponent(viewComponent : Dynamic) : Void
static var NAME : String

The name of the Mediator.

117 |

Typically, a Mediator will be written to serve 118 | one specific control or group controls and so, 119 | will not have a need to be dynamically named.

Back | Index 120 | 121 |
122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/observer/Notification.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.observer.Notification

A base INotification implementation.

117 |

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

119 |

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

122 |

Notifications are not meant to be a replacement for Events. 123 | Generally, IMediator implementors place event listeners on their view components, which they 124 | then handle in the usual way. This may lead to the broadcast of Notifications to 125 | trigger ICommands or to communicate with other IMediators. IProxy and ICommand 126 | instances communicate with each other and IMediators by broadcasting INotifications.

127 |

A key difference between Flash Events and PureMVC 128 | Notifications is that Events follow the 129 | 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy 130 | until some parent component handles the Event, while 131 | PureMVC Notifications follow a 'Publish/Subscribe' 132 | pattern. PureMVC classes need not be related to each other in a 133 | parent/child relationship in order to communicate with one another 134 | using Notifications.

function new(name : String, ?body : Dynamic, ?type : String) : Void
Constructor.
function getBody() : Dynamic
function getName() : String
function getType() : String
function setBody(body : Dynamic) : Void
function setType(type : String) : Void
function toString() : String
Back | Index 135 | 136 |
137 | 138 | 139 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/observer/Notifier.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.observer.Notifier

A Base INotifier implementation.

117 |

MacroCommand, Command, Mediator and Proxy 118 | all have a need to send Notifications.

119 |

The INotifier interface provides a common method called 120 | sendNotification that relieves implementation code of 121 | the necessity to actually construct Notifications.

122 |

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

var facade(dynamic,null) : org.puremvc.haxe.multicore.interfaces.IFacade
function new() : Void
function initializeNotifier(key : String) : Void
function sendNotification(notificationName : String, ?body : Dynamic, ?type : String) : Void
Back | Index 128 | 129 |
130 | 131 | 132 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/observer/Observer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.observer.Observer

A base IObserver implementation.

117 |

An Observer is an object that encapsulates information 118 | about an interested object with a method that should 119 | be called when a particular INotification is broadcast.

120 |

In PureMVC, the Observer class assumes these responsibilities:

121 |
    122 |
  • Encapsulate the notification (callback) method of the interested object.
  • 123 |
  • Encapsulate the notification context (this) of the interested object.
  • 124 |
  • Provide methods for setting the notification method and context.
  • 125 |
  • Provide a method for notifying the interested object.
  • 126 |

function new(notifyMethod : Dynamic -> Void, notifyContext : Dynamic) : Void

Constructor.

127 |

The notification method on the interested object should take 128 | one parameter of type INotification

function compareNotifyContext(object : Dynamic) : Bool
function notifyObserver(notification : org.puremvc.haxe.multicore.interfaces.INotification) : Void
function setNotifyContext(notifyContext : Dynamic) : Void
function setNotifyMethod(notifyMethod : Dynamic -> Void) : Void
Back | Index 129 | 130 |
131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/content/org/puremvc/haxe/multicore/patterns/proxy/Proxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | Back | Index
class org.puremvc.haxe.multicore.patterns.proxy.Proxy

A base IProxy implementation.

117 |

In PureMVC, Proxy classes are used to manage parts of the 118 | application's data model.

119 |

A Proxy might simply manage a reference to a local data object, 120 | in which case interacting with it might involve setting and 121 | getting of its data in synchronous fashion.

122 |

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

function new(?proxyName : String, ?data : Dynamic) : Void
Constructor
function getData() : Dynamic
function getProxyName() : String
function onRegister() : Void
function onRemove() : Void
function setData(data : Dynamic) : Void
static var NAME : String
Back | Index 127 | 128 |
129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Haxe API Documentation 5 | 6 | 16 | 17 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
PureMVC Framework for Haxe: API Documentation
115 | 116 | 117 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/ImportAll.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC haXe Port by Marco Secchi 3 | PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore; 7 | 8 | // core 9 | import org.puremvc.haxe.multicore.core.Controller; 10 | import org.puremvc.haxe.multicore.core.Model; 11 | import org.puremvc.haxe.multicore.core.View; 12 | 13 | // interfaces 14 | import org.puremvc.haxe.multicore.interfaces.ICommand; 15 | import org.puremvc.haxe.multicore.interfaces.IController; 16 | import org.puremvc.haxe.multicore.interfaces.IFacade; 17 | import org.puremvc.haxe.multicore.interfaces.IMediator; 18 | import org.puremvc.haxe.multicore.interfaces.IModel; 19 | import org.puremvc.haxe.multicore.interfaces.INotification; 20 | import org.puremvc.haxe.multicore.interfaces.INotifier; 21 | import org.puremvc.haxe.multicore.interfaces.IObserver; 22 | import org.puremvc.haxe.multicore.interfaces.ICommand; 23 | import org.puremvc.haxe.multicore.interfaces.IProxy; 24 | import org.puremvc.haxe.multicore.interfaces.IView; 25 | 26 | // patterns 27 | import org.puremvc.haxe.multicore.patterns.command.MacroCommand; 28 | import org.puremvc.haxe.multicore.patterns.command.SimpleCommand; 29 | import org.puremvc.haxe.multicore.patterns.facade.Facade; 30 | import org.puremvc.haxe.multicore.patterns.mediator.Mediator; 31 | import org.puremvc.haxe.multicore.patterns.observer.Notification; 32 | import org.puremvc.haxe.multicore.patterns.observer.Notifier; 33 | import org.puremvc.haxe.multicore.patterns.observer.Observer; 34 | import org.puremvc.haxe.multicore.patterns.proxy.Proxy; 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/core/Controller.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.core; 7 | 8 | import org.puremvc.haxe.multicore.core.View; 9 | import org.puremvc.haxe.multicore.interfaces.ICommand; 10 | import org.puremvc.haxe.multicore.interfaces.IView; 11 | import org.puremvc.haxe.multicore.interfaces.IController; 12 | import org.puremvc.haxe.multicore.interfaces.INotification; 13 | import org.puremvc.haxe.multicore.patterns.observer.Observer; 14 | 15 | #if haxe3 16 | import haxe.ds.StringMap; 17 | #else 18 | private typedef StringMap = Hash; 19 | #end 20 | 21 | /** 22 | * A Multiton [IController] implementation. 23 | * 24 | *

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

26 | *
    27 | *
  • Remembering which [ICommand]s are intended to handle which [INotifications].
  • 28 | *
  • Registering itself as an [IObserver] with the [View] for each [INotification] 29 | * that it has an [ICommand] mapping for.
  • 30 | *
  • Creating a new instance of the proper [ICommand] to handle a given [INotification] 31 | * when notified by the [View].
  • 32 | *
  • Calling the [ICommand]'s [execute] method, passing in the [INotification].
  • 33 | *
34 | * 35 | *

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

38 | */ 39 | class Controller implements IController 40 | { 41 | 42 | /** 43 | * Constructor. 44 | * 45 | *

This [IController] implementation is a Multiton, so you cannot 46 | * call the constructor directly, but instead call the static 47 | * Factory method passing the unique key for this instance 48 | * [Controller.getInstance( multitonKey )]

49 | */ 50 | private function new( key: String ) 51 | { 52 | multitonKey = key; 53 | instanceMap.set( multitonKey, this ); 54 | commandMap = new StringMap(); 55 | initializeController(); 56 | } 57 | 58 | /** 59 | * Initialize the Singleton [Controller] instance. 60 | * 61 | *

Called automatically by the constructor.

62 | * 63 | *

Note that if you are using a subclass of [View] 64 | * in your application, you should also subclass [Controller] 65 | * and override the [initializeController] method. 66 | */ 67 | private function initializeController(): Void 68 | { 69 | view = View.getInstance( multitonKey ); 70 | } 71 | 72 | /** 73 | * [Controller] Multiton Factory method. 74 | */ 75 | public static function getInstance( key: String ): IController 76 | { 77 | if ( instanceMap == null ) instanceMap = new StringMap(); 78 | if ( !instanceMap.exists( key ) ) instanceMap.set( key, new Controller( key ) ); 79 | return instanceMap.get( key ); 80 | } 81 | 82 | /** 83 | * If an [ICommand] has previously been registered 84 | * to handle a the given [INotification], then it is executed. 85 | */ 86 | public function executeCommand( note: INotification ): Void 87 | { 88 | var commandClassRef: Class = commandMap.get( note.getName() ); 89 | if ( commandClassRef == null ) return; 90 | 91 | var commandInstance: ICommand = Type.createInstance( commandClassRef, [] ); 92 | commandInstance.initializeNotifier( multitonKey ); 93 | commandInstance.execute( note ); 94 | } 95 | 96 | /** 97 | * Register a particular [ICommand] class as the handler for a particular [INotification]. 98 | * 99 | *

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

102 | * 103 | *

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

105 | */ 106 | public function registerCommand( notificationName: String, commandClassRef: Class ): Void 107 | { 108 | if ( !commandMap.exists( notificationName ) ) 109 | view.registerObserver( notificationName, new Observer( executeCommand, this ) ); 110 | commandMap.set( notificationName, commandClassRef ); 111 | } 112 | 113 | /** 114 | * Check if a Command is registered for a given Notification 115 | */ 116 | public function hasCommand( notificationName: String ): Bool 117 | { 118 | return commandMap.exists( notificationName ); 119 | } 120 | 121 | /** 122 | * Remove a previously registered [ICommand] to [INotification] mapping. 123 | */ 124 | public function removeCommand( notificationName: String ): Void 125 | { 126 | // if the Command is registered... 127 | if ( hasCommand( notificationName ) ) 128 | { 129 | // remove the observer 130 | view.removeObserver( notificationName, this ); 131 | 132 | commandMap.remove( notificationName ); 133 | } 134 | } 135 | 136 | /** 137 | * Remove an IController instance 138 | */ 139 | public function removeController( key: String ): Void 140 | { 141 | instanceMap.remove( key ); 142 | } 143 | 144 | // Local reference to View 145 | private var view: IView; 146 | 147 | // Mapping of Notification names to Command Class references 148 | private var commandMap: StringMap>; 149 | 150 | // The Multiton Key for this Core 151 | private var multitonKey: String; 152 | 153 | // Singleton instance 154 | private static var instanceMap: StringMap; 155 | 156 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/core/Model.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.core; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.IModel; 9 | import org.puremvc.haxe.multicore.interfaces.IProxy; 10 | 11 | #if haxe3 12 | import haxe.ds.StringMap; 13 | #else 14 | private typedef StringMap = Hash; 15 | #end 16 | 17 | /** 18 | * A Singleton [IModel] implementation. 19 | * 20 | *

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

21 | * 22 | *

The [Model] assumes these responsibilities:

23 | *
    24 | *
  • Maintain a cache of [IProxy] instances.
  • 25 | *
  • Provide methods for registering, retrieving, and removing [IProxy] instances.
  • 26 | *
27 | * 28 | *

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

31 | */ 32 | class Model implements IModel 33 | { 34 | /** 35 | * Constructor. 36 | * 37 | *

This [IModel] implementation is a Multiton, 38 | * so you should not call the constructor 39 | * directly, but instead call the static Multiton 40 | * Factory method [Model.getInstance( multitonKey )]

41 | */ 42 | private function new( key: String ) 43 | { 44 | multitonKey = key; 45 | instanceMap.set( multitonKey, this ); 46 | proxyMap = new StringMap(); 47 | initializeModel(); 48 | } 49 | 50 | /** 51 | * Initialize the Singleton [Model] instance. 52 | * 53 | *

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

55 | */ 56 | private function initializeModel(): Void 57 | { 58 | } 59 | 60 | /** 61 | * [Model] Multiton Factory method. 62 | */ 63 | public static function getInstance( key: String ): IModel 64 | { 65 | if ( instanceMap == null ) instanceMap = new StringMap(); 66 | if ( !instanceMap.exists( key ) ) instanceMap.set( key, new Model( key ) ); 67 | return instanceMap.get( key ); 68 | } 69 | 70 | /** 71 | * Register an [IProxy] with the [Model]. 72 | */ 73 | public function registerProxy( proxy: IProxy ): Void 74 | { 75 | proxy.initializeNotifier( multitonKey ); 76 | proxyMap.set( proxy.getProxyName(), proxy ); 77 | proxy.onRegister(); 78 | } 79 | 80 | /** 81 | * Retrieve an [IProxy] from the [Model]. 82 | */ 83 | public function retrieveProxy( proxyName: String ): IProxy 84 | { 85 | return proxyMap.get( proxyName ); 86 | } 87 | 88 | /** 89 | * Check if a [Proxy] is registered 90 | */ 91 | public function hasProxy( proxyName:String ) : Bool 92 | { 93 | return proxyMap.exists( proxyName ); 94 | } 95 | 96 | /** 97 | * Remove an [IProxy] from the [Model]. 98 | */ 99 | public function removeProxy( proxyName: String ): IProxy 100 | { 101 | var proxy: IProxy = proxyMap.get( proxyName ); 102 | if ( proxy != null ) 103 | { 104 | proxyMap.remove( proxyName ); 105 | proxy.onRemove(); 106 | } 107 | return proxy; 108 | } 109 | 110 | /** 111 | * Remove an IModel instance 112 | */ 113 | public function removeModel( key: String ): Void 114 | { 115 | instanceMap.remove( key ); 116 | } 117 | 118 | // Mapping of proxyNames to [IProxy] instances 119 | private var proxyMap: StringMap; 120 | 121 | // Singleton instance 122 | private static var instanceMap: StringMap; 123 | 124 | // The Multiton Key for this Core 125 | private var multitonKey: String; 126 | 127 | 128 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/ICommand.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Command. 10 | */ 11 | #if haxe3 12 | interface ICommand extends INotifier 13 | #else 14 | interface ICommand implements INotifier 15 | #end 16 | { 17 | /** 18 | * Execute the [ICommand]'s logic to handle a given [INotification]. 19 | */ 20 | function execute( notification: INotification ): Void; 21 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IController.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Controller. 10 | * 11 | *

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

14 | *
    15 | *
  • Remembering which [ICommand]s 16 | * are intended to handle which [INotifications].
  • 17 | *
  • Registering itself as an [IObserver] with 18 | * the [View] for each [INotification] 19 | * that it has an [ICommand] mapping for.
  • 20 | *
  • Creating a new instance of the proper [ICommand] 21 | * to handle a given [INotification] when notified by the [View].
  • 22 | *
  • Calling the [ICommand]'s [execute] 23 | * method, passing in the [INotification].
  • 24 | *
25 | */ 26 | interface IController 27 | { 28 | /** 29 | * Register a particular [ICommand] class as the handler 30 | * for a particular [INotification]. 31 | */ 32 | function registerCommand( notificationName: String, commandClassRef: Class ): Void; 33 | 34 | /** 35 | * Execute the [ICommand] previously registered as the 36 | * handler for [INotification]s with the given notification name. 37 | */ 38 | function executeCommand( notification: INotification ): Void; 39 | 40 | /** 41 | * Remove a previously registered [ICommand] to [INotification] mapping. 42 | */ 43 | function removeCommand( notificationName: String ): Void; 44 | 45 | /** 46 | * Check if a Command is registered for a given Notification 47 | */ 48 | function hasCommand( notificationName: String ): Bool; 49 | 50 | /** 51 | * Remove an IController instance 52 | */ 53 | function removeController( key: String ): Void; 54 | 55 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IFacade.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Facade. 10 | * 11 | *

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

14 | * 15 | *

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

18 | */ 19 | #if haxe3 20 | interface IFacade extends INotifier 21 | #else 22 | interface IFacade implements INotifier 23 | #end 24 | { 25 | /** 26 | * Register an [IProxy] with the [Model] by name. 27 | */ 28 | function registerProxy( proxy: IProxy ): Void; 29 | 30 | /** 31 | * Retrieve a [IProxy] from the [Model] by name. 32 | */ 33 | function retrieveProxy( proxyName: String ): IProxy; 34 | 35 | /** 36 | * Remove an [IProxy] instance from the [Model] by name. 37 | */ 38 | function removeProxy( proxyName: String ): IProxy; 39 | 40 | /** 41 | * Check if a [Proxy] is registered 42 | */ 43 | function hasProxy( proxyName: String ): Bool; 44 | 45 | /** 46 | * Register an [ICommand] with the [Controller]. 47 | */ 48 | function registerCommand( noteName: String, commandClassRef: Class ) : Void; 49 | 50 | /** 51 | * Remove a previously registered [ICommand] to [INotification] mapping from the Controller. 52 | */ 53 | function removeCommand( notificationName: String ): Void; 54 | 55 | /** 56 | * Check if a [Command] is registered for a given Notification 57 | */ 58 | function hasCommand( notificationName: String ): Bool; 59 | 60 | /** 61 | * Register an [IMediator] instance with the [View]. 62 | */ 63 | function registerMediator( mediator: IMediator ) :Void; 64 | 65 | /** 66 | * Retrieve an [IMediator] instance from the [View]. 67 | */ 68 | function retrieveMediator( mediatorName: String ): IMediator; 69 | 70 | /** 71 | * Remove a [IMediator] instance from the [View]. 72 | */ 73 | function removeMediator( mediatorName: String ): IMediator; 74 | 75 | /** 76 | * Check if a [Mediator] is registered or not 77 | */ 78 | function hasMediator( mediatorName: String ): Bool; 79 | 80 | /** 81 | * Create and send an [INotification]. 82 | */ 83 | function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void; 84 | 85 | /** 86 | * Notify the [IObservers] for a particular [INotification]. 87 | * 88 | *

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

91 | * 92 | *

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

95 | */ 96 | function notifyObservers( note: INotification ): Void; 97 | 98 | /** 99 | * Remove a Core 100 | */ 101 | function removeCore( key: String ) : Void; 102 | 103 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IMediator.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Mediator. 10 | * 11 | *

In PureMVC, [IMediator] implementors assume these responsibilities:

12 | *
    13 | *
  • Implement a common method which returns a list of all [INotification]s 14 | * the [IMediator] has interest in.
  • 15 | *
  • Implement a common notification (callback) method.
  • 16 | *
17 | *

Additionally, [IMediator]s typically:

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

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

31 | * 32 | *

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

36 | */ 37 | #if haxe3 38 | interface IMediator extends INotifier 39 | #else 40 | interface IMediator implements INotifier 41 | #end 42 | { 43 | 44 | /** 45 | * Get the [IMediator] instance name 46 | */ 47 | function getMediatorName(): String; 48 | 49 | /** 50 | * Get the [IMediator]'s view component. 51 | */ 52 | function getViewComponent(): Dynamic; 53 | 54 | /** 55 | * Set the [IMediator]'s view component. 56 | */ 57 | function setViewComponent( viewComponent: Dynamic ): Void; 58 | 59 | /** 60 | * List [INotification] interests. 61 | */ 62 | function listNotificationInterests(): Array; 63 | 64 | /** 65 | * Handle an [INotification]. 66 | */ 67 | function handleNotification( notification: INotification ): Void; 68 | 69 | /** 70 | * Called by the [View] when the [Mediator] is registered 71 | */ 72 | function onRegister(): Void; 73 | 74 | /** 75 | * Called by the [View] when the [Mediator] is removed 76 | */ 77 | function onRemove(): Void; 78 | 79 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Model. 10 | * 11 | *

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

13 | * 14 | *

An [IModel] assumes these responsibilities:

15 | *
    16 | *
  • Maintain a cache of [IProxy] instances
  • 17 | *
  • Provide methods for registering, retrieving, and removing [IProxy] instances
  • 18 | *
19 | */ 20 | interface IModel 21 | { 22 | /** 23 | * Register an [IProxy] instance with the [Model]. 24 | */ 25 | function registerProxy( proxy: IProxy ): Void; 26 | 27 | /** 28 | * Retrieve an [IProxy] instance from the Model. 29 | */ 30 | function retrieveProxy( proxyName: String ): IProxy; 31 | 32 | /** 33 | * Remove an [IProxy] instance from the Model. 34 | */ 35 | function removeProxy( proxyName: String ): IProxy; 36 | 37 | /** 38 | * Check if a [Proxy] is registered 39 | */ 40 | function hasProxy( proxyName: String ): Bool; 41 | 42 | /** 43 | * Remove an IModel instance 44 | */ 45 | function removeModel( key: String ): Void; 46 | 47 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/INotification.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Notification. 10 | * 11 | *

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

13 | * 14 | *

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

17 | * 18 | *

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

25 | * 26 | *

A key difference between Flash [Event]s and PureMVC 27 | * [Notification]s is that [Event]s follow the 28 | * 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy 29 | * until some parent component handles the [Event], while 30 | * PureMVC [Notification]s follow a 'Publish/Subscribe' 31 | * pattern. PureMVC classes need not be related to each other in a 32 | * parent/child relationship in order to communicate with one another 33 | * using [Notification]s. 34 | */ 35 | interface INotification 36 | { 37 | /** 38 | * Get the name of the [INotification] instance. 39 | * No setter, should be set by constructor only 40 | */ 41 | function getName(): String; 42 | 43 | /** 44 | * Set the body of the [INotification] instance 45 | */ 46 | function setBody( body: Dynamic ): Void; 47 | 48 | /** 49 | * Get the body of the [INotification] instance 50 | */ 51 | function getBody(): Dynamic; 52 | 53 | /** 54 | * Set the type of the [INotification] instance 55 | */ 56 | function setType( type: String ): Void; 57 | 58 | /** 59 | * Get the type of the [INotification] instance 60 | */ 61 | function getType(): String; 62 | 63 | /** 64 | * Get the string representation of the [INotification] instance 65 | */ 66 | function toString(): String; 67 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/INotifier.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Notifier. 10 | * 11 | *

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

13 | * 14 | *

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

17 | * 18 | *

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

24 | */ 25 | interface INotifier 26 | { 27 | /** 28 | * Send a [INotification]. 29 | * 30 | *

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

32 | */ 33 | function sendNotification( notificationName: String, ?body: Dynamic, ?type: String ): Void; 34 | 35 | /** 36 | * Initialize this INotifier instance. 37 | * 38 | *

This is how a Notifier gets its multitonKey. 39 | * Calls to sendNotification or to access the 40 | * facade will fail until after this method 41 | * has been called.

42 | */ 43 | function initializeNotifier( key: String ): Void; 44 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IObserver.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Observer. 10 | * 11 | *

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

    13 | *
  • Encapsulate the notification (callback) method of the interested object.
  • 14 | *
  • Encapsulate the notification context (this) of the interested object.
  • 15 | *
  • Provide methods for setting the interested object' notification method and context.
  • 16 | *
  • Provide a method for notifying the interested object.
  • 17 | *
18 | * 19 | *

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

21 | * 22 | *

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

25 | * 26 | *

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

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

35 | */ 36 | interface IObserver 37 | { 38 | /** 39 | * Set the notification method. 40 | * 41 | *

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

42 | */ 43 | function setNotifyMethod( notifyMethod: Dynamic -> Void ): Void; 44 | 45 | /** 46 | * Set the notification context. 47 | */ 48 | function setNotifyContext( notifyContext: Dynamic ): Void; 49 | 50 | /** 51 | * Notify the interested object. 52 | */ 53 | function notifyObserver( notification: INotification ): Void; 54 | 55 | /** 56 | * Compare the given object to the notificaiton context object. 57 | */ 58 | function compareNotifyContext( object: Dynamic ): Bool; 59 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IProxy.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC Proxy. 10 | * 11 | *

In PureMVC, [IProxy] implementors assume these responsibilities:

12 | *
    13 | *
  • Implement a common method which returns the name of the [Proxy].
  • 14 | *
15 | *

Additionally, [IProxy]s typically:

16 | *
    17 | *
  • Maintain references to one or more pieces of model data.
  • 18 | *
  • Provide methods for manipulating that data.
  • 19 | *
  • Generate [INotifications] when their model data changes.
  • 20 | *
  • Expose their name as a [public static var] called [NAME].
  • 21 | *
  • Encapsulate interaction with local or remote services used to fetch and persist model data.
  • 22 | *
23 | */ 24 | #if haxe3 25 | interface IProxy extends INotifier 26 | #else 27 | interface IProxy implements INotifier 28 | #end 29 | { 30 | 31 | /** 32 | * Get the [Proxy] name 33 | */ 34 | function getProxyName(): String; 35 | 36 | /** 37 | * Set the data object 38 | */ 39 | function setData( data: Dynamic ): Void; 40 | 41 | /** 42 | * Get the data object 43 | */ 44 | function getData(): Dynamic; 45 | 46 | /** 47 | * Called by the Model when the [Proxy] is registered 48 | */ 49 | function onRegister(): Void; 50 | 51 | /** 52 | * Called by the Model when the [Proxy] is removed 53 | */ 54 | function onRemove(): Void; 55 | 56 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/interfaces/IView.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.interfaces; 7 | 8 | /** 9 | * The interface definition for a PureMVC View. 10 | * 11 | *

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

    13 | *
  • Maintain a cache of [IMediator] instances.
  • 14 | *
  • Provide methods for registering, retrieving, and removing [IMediators].
  • 15 | *
  • Managing the observer lists for each [INotification] in the application.
  • 16 | *
  • Providing a method for attaching [IObservers] to an [INotification]'s observer list.
  • 17 | *
  • Providing a method for broadcasting an [INotification].
  • 18 | *
  • Notifying the [IObservers] of a given [INotification] when it broadcast.
  • 19 | *
20 | */ 21 | interface IView 22 | { 23 | /** 24 | * Register an [IObserver] to be notified of [INotifications] with a given name. 25 | */ 26 | function registerObserver ( noteName: String, observer: IObserver ): Void; 27 | 28 | /** 29 | * Remove a group of observers from the observer list for a given Notification name. 30 | */ 31 | function removeObserver( notificationName: String, notifyContext: Dynamic ): Void; 32 | 33 | /** 34 | * Notify the [IObservers] for a particular [INotification]. 35 | * 36 | *

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

39 | */ 40 | function notifyObservers( note: INotification ): Void; 41 | 42 | /** 43 | * Register an [IMediator] instance with the [View]. 44 | * 45 | *

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

47 | * 48 | *

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

53 | */ 54 | function registerMediator( mediator: IMediator ): Void; 55 | 56 | /** 57 | * Retrieve an [IMediator] from the [View]. 58 | */ 59 | function retrieveMediator( mediatorName: String ): IMediator; 60 | 61 | /** 62 | * Remove an [IMediator] from the [View]. 63 | */ 64 | function removeMediator( mediatorName: String ): IMediator; 65 | 66 | /** 67 | * Check if a [Mediator] is registered or not 68 | */ 69 | function hasMediator( mediatorName: String ): Bool; 70 | 71 | /** 72 | * Remove an IView instance 73 | */ 74 | function removeView( key: String ): Void; 75 | 76 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/command/MacroCommand.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.command; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.ICommand; 9 | import org.puremvc.haxe.multicore.interfaces.INotification; 10 | import org.puremvc.haxe.multicore.interfaces.INotifier; 11 | import org.puremvc.haxe.multicore.patterns.observer.Notifier; 12 | 13 | /** 14 | * A base [ICommand] implementation that executes other [ICommand]s. 15 | * 16 | *

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

18 | * 19 | *

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

24 | * 25 | *

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

30 | */ 31 | #if haxe3 32 | class MacroCommand extends Notifier implements ICommand 33 | #else 34 | class MacroCommand extends Notifier, implements ICommand 35 | #end 36 | { 37 | 38 | private var subCommands: List>; 39 | 40 | /** 41 | * Constructor. 42 | * 43 | *

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

46 | * 47 | *

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

50 | */ 51 | public function new() 52 | { 53 | super(); 54 | subCommands = new List(); 55 | initializeMacroCommand(); 56 | } 57 | 58 | /** 59 | * Initialize the [MacroCommand]. 60 | * 61 | *

In your subclass, override this method to 62 | * initialize the [MacroCommand]'s SubCommand 63 | * list with [ICommand] class references. 64 | * 65 | *

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

67 | */ 68 | private function initializeMacroCommand(): Void 69 | { 70 | } 71 | 72 | /** 73 | * Add a SubCommand. 74 | * 75 | *

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

77 | */ 78 | private function addSubCommand( commandClassRef: Class ): Void 79 | { 80 | subCommands.add( commandClassRef ); 81 | } 82 | 83 | /** 84 | * Execute this [MacroCommand]'s SubCommands. 85 | * 86 | *

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

88 | */ 89 | public function execute( notification: INotification ): Void 90 | { 91 | while ( !subCommands.isEmpty() ) 92 | { 93 | var commandClassRef: Class = subCommands.pop(); 94 | var commandInstance: ICommand = Type.createInstance( commandClassRef, [] ); 95 | commandInstance.initializeNotifier( multitonKey ); 96 | commandInstance.execute( notification ); 97 | } 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/command/SimpleCommand.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | 7 | package org.puremvc.haxe.multicore.patterns.command; 8 | 9 | import org.puremvc.haxe.multicore.interfaces.INotification; 10 | import org.puremvc.haxe.multicore.interfaces.ICommand; 11 | import org.puremvc.haxe.multicore.interfaces.INotifier; 12 | import org.puremvc.haxe.multicore.patterns.observer.Notifier; 13 | 14 | /** 15 | * A base [ICommand] implementation. 16 | * 17 | *

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

19 | */ 20 | #if haxe3 21 | class SimpleCommand extends Notifier implements ICommand 22 | #else 23 | class SimpleCommand extends Notifier, implements ICommand 24 | #end 25 | { 26 | /** 27 | * Fulfill the use-case initiated by the given [INotification]. 28 | * 29 | *

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

32 | */ 33 | public function execute( notification: INotification ) : Void 34 | { 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/mediator/Mediator.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.mediator; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.INotification; 9 | import org.puremvc.haxe.multicore.interfaces.INotifier; 10 | import org.puremvc.haxe.multicore.interfaces.IMediator; 11 | import org.puremvc.haxe.multicore.patterns.observer.Notifier; 12 | 13 | /** 14 | * A base [IMediator] implementation. 15 | */ 16 | #if haxe3 17 | class Mediator extends Notifier implements IMediator 18 | #else 19 | class Mediator extends Notifier, implements IMediator 20 | #end 21 | { 22 | 23 | /** 24 | * The name of the [Mediator]. 25 | * 26 | *

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

29 | */ 30 | public static var NAME: String = 'Mediator'; 31 | 32 | /** 33 | * Constructor. 34 | */ 35 | public function new( ?mediatorName: String = null, ?viewComponent: Dynamic = null ) 36 | { 37 | super(); 38 | this.mediatorName = if( mediatorName != null ) mediatorName else NAME; 39 | this.viewComponent = viewComponent; 40 | } 41 | 42 | /** 43 | * Get the name of the [Mediator]. 44 | *

Override in subclass!

45 | */ 46 | public function getMediatorName(): String 47 | { 48 | return mediatorName; 49 | } 50 | 51 | /** 52 | * Set the [IMediator]'s view component. 53 | */ 54 | public function setViewComponent( viewComponent: Dynamic ): Void 55 | { 56 | this.viewComponent = viewComponent; 57 | } 58 | 59 | /** 60 | * Get the [Mediator]'s view component. 61 | */ 62 | public function getViewComponent(): Dynamic 63 | { 64 | return viewComponent; 65 | } 66 | 67 | /** 68 | * List the [INotification] names this 69 | * [Mediator] is interested in being notified of. 70 | */ 71 | public function listNotificationInterests(): Array 72 | { 73 | return []; 74 | } 75 | 76 | /** 77 | * Handle [INotification]s. 78 | * 79 | *

Typically this will be handled in a switch statement, 80 | * with one 'case' entry per [INotification] 81 | * the [Mediator] is interested in. 82 | */ 83 | public function handleNotification( notification: INotification ): Void 84 | { 85 | 86 | } 87 | 88 | /** 89 | * Called by the View when the Mediator is registered 90 | */ 91 | public function onRegister(): Void 92 | { 93 | } 94 | 95 | /** 96 | * Called by the View when the Mediator is removed 97 | */ 98 | public function onRemove( ): Void 99 | { 100 | 101 | } 102 | 103 | // the mediator name 104 | private var mediatorName: String; 105 | 106 | // The view component 107 | private var viewComponent: Dynamic; 108 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/observer/Notification.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.observer; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.INotification; 9 | 10 | /** 11 | * A base [INotification] implementation. 12 | * 13 | *

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

15 | * 16 | *

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

19 | * 20 | *

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

25 | * 26 | *

A key difference between Flash [Event]s and PureMVC 27 | * [Notification]s is that [Event]s follow the 28 | * 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy 29 | * until some parent component handles the [Event], while 30 | * PureMVC [Notification]s follow a 'Publish/Subscribe' 31 | * pattern. PureMVC classes need not be related to each other in a 32 | * parent/child relationship in order to communicate with one another 33 | * using [Notification]s. 34 | */ 35 | class Notification implements INotification 36 | { 37 | /** 38 | * Constructor. 39 | */ 40 | public function new( name: String, ?body: Dynamic = null, ?type: String = null ) 41 | { 42 | this.name = name; 43 | this.body = body; 44 | this.type = type; 45 | } 46 | 47 | /** 48 | * Get the name of the [Notification] instance. 49 | */ 50 | public function getName(): String 51 | { 52 | return name; 53 | } 54 | 55 | /** 56 | * Set the body of the [Notification] instance. 57 | */ 58 | public function setBody( body: Dynamic ): Void 59 | { 60 | this.body = body; 61 | } 62 | 63 | /** 64 | * Get the body of the [Notification] instance. 65 | */ 66 | public function getBody(): Dynamic 67 | { 68 | return body; 69 | } 70 | 71 | /** 72 | * Set the type of the [Notification] instance. 73 | */ 74 | public function setType( type: String ): Void 75 | { 76 | this.type = type; 77 | } 78 | 79 | /** 80 | * Get the type of the [Notification] instance. 81 | */ 82 | public function getType(): String 83 | { 84 | return type; 85 | } 86 | 87 | /** 88 | * Get the string representation of the [Notification] instance. 89 | */ 90 | public function toString(): String 91 | { 92 | var msg: String = "Notification Name: " + getName(); 93 | msg += "\nBody:" + if( body == null ) "null" else body.toString(); 94 | msg += "\nType:" + if( type == null ) "null" else type; 95 | return msg; 96 | } 97 | 98 | // the name of the notification instance 99 | private var name : String; 100 | 101 | // the type of the notification instance 102 | private var type : String; 103 | 104 | // the body of the notification instance 105 | private var body : Dynamic; 106 | 107 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/observer/Notifier.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.observer; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.IFacade; 9 | import org.puremvc.haxe.multicore.interfaces.INotifier; 10 | import org.puremvc.haxe.multicore.patterns.observer.Notification; 11 | import org.puremvc.haxe.multicore.patterns.facade.Facade; 12 | 13 | /** 14 | * A Base [INotifier] implementation. 15 | * 16 | *

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

18 | * 19 | *

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

22 | * 23 | *

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

29 | */ 30 | class Notifier implements INotifier 31 | { 32 | public function new() 33 | { 34 | } 35 | 36 | /** 37 | * Send an [INotification]s. 38 | * 39 | *

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

41 | */ 42 | public function sendNotification( notificationName: String, ?body: Dynamic = null, ?type: String = null ): Void 43 | { 44 | facade.sendNotification( notificationName, body, type ); 45 | } 46 | 47 | /** 48 | * Initialize this INotifier instance. 49 | * 50 | *

This is how a Notifier gets its multitonKey. 51 | * Calls to sendNotification or to access the 52 | * facade will fail until after this method 53 | * has been called.

54 | * 55 | *

Mediators, Commands or Proxies may override 56 | * this method in order to send notifications 57 | * or access the Multiton Facade instance as 58 | * soon as possible. They CANNOT access the facade 59 | * in their constructors, since this method will not 60 | * yet have been called.

61 | */ 62 | public function initializeNotifier( key: String ): Void 63 | { 64 | multitonKey = key; 65 | } 66 | 67 | #if haxe3 68 | public var facade( get, null ): IFacade; 69 | #else 70 | public var facade( get_facade, null ): IFacade; 71 | #end 72 | 73 | // Return the Multiton Facade instance 74 | private function get_facade(): IFacade 75 | { 76 | if ( multitonKey == null ) throw MULTITON_MSG; 77 | return Facade.getInstance( multitonKey ); 78 | } 79 | 80 | private function getFacade() : IFacade 81 | { 82 | return facade; 83 | } 84 | 85 | // The Multiton Key for this app 86 | private var multitonKey : String; 87 | 88 | // Message Constants 89 | private static inline var MULTITON_MSG: String = "multitonKey for this Notifier not yet initialized!"; 90 | 91 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/observer/Observer.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC MultiCore haXe Port by Marco Secchi 3 | PureMVC MultiCore - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.observer; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.IObserver; 9 | import org.puremvc.haxe.multicore.interfaces.INotification; 10 | 11 | /** 12 | * A base [IObserver] implementation. 13 | * 14 | *

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

17 | * 18 | *

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

19 | *
    20 | *
  • Encapsulate the notification (callback) method of the interested object.
  • 21 | *
  • Encapsulate the notification context (this) of the interested object.
  • 22 | *
  • Provide methods for setting the notification method and context.
  • 23 | *
  • Provide a method for notifying the interested object.
  • 24 | *
25 | */ 26 | class Observer implements IObserver 27 | { 28 | 29 | private var notify: Dynamic -> Void; 30 | private var context: Dynamic; 31 | 32 | /** 33 | * Constructor. 34 | * 35 | *

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

37 | */ 38 | public function new( notifyMethod: Dynamic -> Void, notifyContext: Dynamic ): Void 39 | { 40 | setNotifyMethod( notifyMethod ); 41 | setNotifyContext( notifyContext ); 42 | } 43 | 44 | /** 45 | * Set the notification method. 46 | * 47 | *

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

48 | */ 49 | public function setNotifyMethod( notifyMethod: Dynamic -> Void ): Void 50 | { 51 | notify = notifyMethod; 52 | } 53 | 54 | /** 55 | * Set the notification context. 56 | */ 57 | public function setNotifyContext( notifyContext: Dynamic ): Void 58 | { 59 | context = notifyContext; 60 | } 61 | 62 | /** 63 | * Get the notification method. 64 | */ 65 | private function getNotifyMethod(): Dynamic -> Void 66 | { 67 | return notify; 68 | } 69 | 70 | /** 71 | * Get the notification context. 72 | */ 73 | private function getNotifyContext(): Dynamic 74 | { 75 | return context; 76 | } 77 | 78 | /** 79 | * Notify the interested object. 80 | */ 81 | public function notifyObserver( notification: INotification ): Void 82 | { 83 | getNotifyMethod()( notification ); 84 | } 85 | 86 | /** 87 | * Compare an object to the notification context. 88 | */ 89 | public function compareNotifyContext( object: Dynamic ): Bool 90 | { 91 | return object == this.context; 92 | } 93 | } -------------------------------------------------------------------------------- /src/org/puremvc/haxe/multicore/patterns/proxy/Proxy.hx: -------------------------------------------------------------------------------- 1 | /* 2 | PureMVC haXe Port by Marco Secchi 3 | PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 4 | Your reuse is governed by the Creative Commons Attribution 3.0 License 5 | */ 6 | package org.puremvc.haxe.multicore.patterns.proxy; 7 | 8 | import org.puremvc.haxe.multicore.interfaces.IProxy; 9 | import org.puremvc.haxe.multicore.interfaces.INotifier; 10 | import org.puremvc.haxe.multicore.patterns.observer.Notifier; 11 | 12 | /** 13 | * A base [IProxy] implementation. 14 | * 15 | *

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

17 | * 18 | *

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

21 | * 22 | *

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

27 | */ 28 | #if haxe3 29 | class Proxy extends Notifier implements IProxy 30 | #else 31 | class Proxy extends Notifier, implements IProxy 32 | #end 33 | { 34 | 35 | public static var NAME: String = 'Proxy'; 36 | 37 | /** 38 | * Constructor 39 | */ 40 | public function new( ?proxyName: String = null, ?data: Dynamic = null ) 41 | { 42 | super(); 43 | this.proxyName = if( proxyName != null ) proxyName else NAME; 44 | if ( data != null ) setData( data ); 45 | } 46 | 47 | /** 48 | * Get the proxy name 49 | */ 50 | public function getProxyName(): String 51 | { 52 | return proxyName; 53 | } 54 | 55 | /** 56 | * Set the data object 57 | */ 58 | public function setData( data: Dynamic ): Void 59 | { 60 | this.data = data; 61 | } 62 | 63 | /** 64 | * Get the data object 65 | */ 66 | public function getData(): Dynamic 67 | { 68 | return data; 69 | } 70 | 71 | /** 72 | * Called by the [Model] when the [Proxy] is registered 73 | */ 74 | public function onRegister(): Void 75 | { 76 | 77 | } 78 | 79 | /** 80 | * Called by the [Model] when the [Proxy] is removed 81 | */ 82 | public function onRemove(): Void 83 | { 84 | 85 | } 86 | 87 | // the proxy name 88 | private var proxyName: String; 89 | 90 | // the data object 91 | private var data: Dynamic; 92 | } --------------------------------------------------------------------------------