Skip to content

Commit 55cb81f

Browse files
author
Cliff Hall
committed
* Facade and IFacade get removeCore method
* Model and IModel get removeModel method * View and IView get removeView method * Controller and IController get removeController method
1 parent 4dd237e commit 55cb81f

File tree

8 files changed

+79
-7
lines changed

8 files changed

+79
-7
lines changed

src/org/puremvc/as3/multicore/core/Controller.as

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,23 @@ package org.puremvc.as3.multicore.core
161161
commandMap[ notificationName ] = null;
162162
}
163163

164+
/**
165+
* Remove an IController instance
166+
*
167+
* @param multitonKey of IController instance to remove
168+
*/
169+
public function removeController( key:String ):void
170+
{
171+
delete instanceMap[ key ];
172+
}
173+
164174
// Local reference to View
165175
protected var view : IView;
166176

167177
// Mapping of Notification names to Command Class references
168178
protected var commandMap : Array;
169179

170-
// The Multiton Key for this app
180+
// The Multiton Key for this Core
171181
protected var multitonKey : String;
172182

173183
// Singleton instance

src/org/puremvc/as3/multicore/core/Model.as

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,27 @@ package org.puremvc.as3.multicore.core
130130
return proxy;
131131
}
132132

133+
/**
134+
* Remove an IModel instance
135+
*
136+
* @param multitonKey of IModel instance to remove
137+
*/
138+
public function removeModel( key:String ):void
139+
{
140+
delete instanceMap[ key ];
141+
}
142+
133143
// Mapping of proxyNames to IProxy instances
134144
protected var proxyMap : Array;
135145

136146
// Singleton instance
137147
protected static var instanceMap:Array = new Array();
138148

139-
// The Multiton Key for this app
149+
// The Multiton Key for this Core
140150
protected var multitonKey : String;
141151

142152
// Message Constants
143-
protected const MULTITON_MSG: String = "Model instance for this Multiton key already constructed!";
153+
protected const MULTITON_MSG:String = "Model instance for this Multiton key already constructed!";
144154

145155
}
146156

src/org/puremvc/as3/multicore/core/View.as

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ package org.puremvc.as3.multicore.core
233233
return mediatorMap[ mediatorName ] != null;
234234
}
235235

236+
/**
237+
* Remove an IView instance
238+
*
239+
* @param multitonKey of IView instance to remove
240+
*/
241+
public function removeView( key:String ):void
242+
{
243+
delete instanceMap[ key ];
244+
}
245+
236246
// Mapping of Mediator names to Mediator instances
237247
protected var mediatorMap : Array;
238248

@@ -242,10 +252,10 @@ package org.puremvc.as3.multicore.core
242252
// Singleton instance
243253
protected static var instanceMap : Array = new Array();
244254

245-
// The Multiton Key for this app
255+
// The Multiton Key for this Core
246256
protected var multitonKey : String;
247257

248258
// Message Constants
249-
protected const MULTITON_MSG: String = "View instance for this Multiton key already constructed!";
259+
protected const MULTITON_MSG:String = "View instance for this Multiton key already constructed!";
250260
}
251261
}

src/org/puremvc/as3/multicore/interfaces/IController.as

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@ package org.puremvc.as3.multicore.interfaces
6060
* @return whether a Command is currently registered for the given <code>notificationName</code>.
6161
*/
6262
function hasCommand( notificationName:String ) : Boolean;
63+
64+
/**
65+
* Remove an IController instance
66+
*
67+
* @param multitonKey of IController instance to remove
68+
*/
69+
function removeController( key:String ):void
70+
71+
6372
}
6473
}

src/org/puremvc/as3/multicore/interfaces/IFacade.as

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,11 @@ package org.puremvc.as3.multicore.interfaces
112112
*/
113113
function hasMediator( mediatorName:String ) : Boolean;
114114

115+
/**
116+
* Remove a Core
117+
*
118+
* @param multitonKey of the Core to remove
119+
*/
120+
function removeCore( key:String ) : void;
115121
}
116122
}

src/org/puremvc/as3/multicore/interfaces/IModel.as

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,11 @@ package org.puremvc.as3.multicore.interfaces
5353
*/
5454
function hasProxy( proxyName:String ) : Boolean;
5555

56+
/**
57+
* Remove an IModel instance
58+
*
59+
* @param multitonKey of IModel instance to remove
60+
*/
61+
function removeModel( key:String ):void;
5662
}
5763
}

src/org/puremvc/as3/multicore/interfaces/IView.as

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ package org.puremvc.as3.multicore.interfaces
9191
* @return whether a Mediator is registered with the given <code>mediatorName</code>.
9292
*/
9393
function hasMediator( mediatorName:String ) : Boolean;
94-
94+
95+
/**
96+
* Remove an IView instance
97+
*
98+
* @param multitonKey of IView instance to remove
99+
*/
100+
function removeView( key:String ):void
95101
}
96102

97103
}

src/org/puremvc/as3/multicore/patterns/facade/Facade.as

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ package org.puremvc.as3.multicore.patterns.facade
307307
multitonKey = key;
308308
}
309309

310+
/**
311+
* Remove a Core
312+
*
313+
* @param multitonKey of the Core to remove
314+
*/
315+
public function removeCore( key:String ) : void
316+
{
317+
// remove the model, view, controller
318+
// and facade instances for this key
319+
model.removeModel( key );
320+
view.removeView( key );
321+
controller.removeController( key );
322+
delete instanceMap[ key ];
323+
}
324+
310325
// References to Model, View and Controller
311326
protected var controller : IController;
312327
protected var model : IModel;
@@ -319,7 +334,7 @@ package org.puremvc.as3.multicore.patterns.facade
319334
protected static var instanceMap : Array = new Array();
320335

321336
// Message Constants
322-
protected const MULTITON_MSG: String = "Facade instance for this Multiton key already constructed!";
337+
protected const MULTITON_MSG:String = "Facade instance for this Multiton key already constructed!";
323338

324339
}
325340
}

0 commit comments

Comments
 (0)