Skip to content

Commit ff45262

Browse files
committed
update
unit tests update
1 parent 02b84cc commit ff45262

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+347
-95
lines changed

bin/cjs/puremvc.cjs renamed to bin/cjs/index.cjs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class Observer {
3434
* <P>The notification method on the interested object should take
3535
* one parameter of type `Notification`</P>
3636
*
37-
* @param {function(Notification):void} notifyMethod
38-
* @param {Object} notifyContext
37+
* @param {function(Notification):void | null} [notify = null]
38+
* @param {Object | null} [context = null]
3939
*/
40-
constructor(notifyMethod, notifyContext) {
41-
this._notifyMethod = notifyMethod;
42-
this._notifyContext = notifyContext;
40+
constructor(notify = null, context = null) {
41+
this._notifyMethod = notify;
42+
this._notifyContext = context;
4343
}
4444

4545
/**
@@ -420,10 +420,10 @@ class Controller {
420420
* passing the unique key for this instance
421421
* `Controller.getInstance( multitonKey )`</P>
422422
*
423-
* @throws {Error} Error if instance for this Multiton key has already been constructed
424-
*
425423
* @constructor
426424
* @param {string} key
425+
*
426+
* @throws {Error} Error if instance for this Multiton key has already been constructed
427427
*/
428428
constructor(key) {
429429
if (Controller.instanceMap[key] != null) throw new Error(Controller.MULTITON_MSG);
@@ -592,7 +592,6 @@ class Controller {
592592
*
593593
* @class Model
594594
*/
595-
596595
class Model {
597596

598597
/**
@@ -722,7 +721,6 @@ class Model {
722721
*/
723722

724723
/**
725-
*
726724
* A base `Notification` implementation.
727725
*
728726
* <P>PureMVC does not rely upon underlying event models such
@@ -780,7 +778,7 @@ class Notification {
780778
/**
781779
* Get the body of the `Notification` instance.
782780
*
783-
* @returns {Object}
781+
* @returns {Object | null}
784782
*/
785783
get body() {
786784
return this._body;
@@ -858,6 +856,7 @@ class Facade {
858856
*
859857
* @constructor
860858
* @param {string} key
859+
*
861860
* @throws {Error} Error if instance for this Multiton key has already been constructed
862861
*/
863862
constructor(key) {
@@ -1022,7 +1021,7 @@ class Facade {
10221021
}
10231022

10241023
/**
1025-
* Check if a Proxy is registered
1024+
* Check if a `Proxy` is registered
10261025
*
10271026
* @param {string} proxyName
10281027
* @returns {boolean} whether a Proxy is currently registered with the given `proxyName`.
@@ -1061,7 +1060,7 @@ class Facade {
10611060
}
10621061

10631062
/**
1064-
* Check if a Mediator is registered or not
1063+
* Check if a `Mediator` is registered or not
10651064
*
10661065
* @param {string} mediatorName
10671066
* @returns {boolean} whether a Mediator is registered with the given `mediatorName`.
@@ -1101,7 +1100,7 @@ class Facade {
11011100
* compatibility, and to allow you to send custom
11021101
* notification classes using the facade.</P>
11031102
*
1104-
* <P>Usually you should just call sendNotification
1103+
* <P>Usually you should just call `sendNotification`
11051104
* and pass the parameters, never having to
11061105
* construct the notification yourself.</P>
11071106
*
@@ -1440,10 +1439,10 @@ class Mediator extends Notifier {
14401439
* Constructor.
14411440
*
14421441
* @constructor
1443-
* @param {string} mediatorName
1444-
* @param {Object} [viewComponent] viewComponent
1442+
* @param {string | null} [mediatorName=null]
1443+
* @param {Object | null} [viewComponent=null]
14451444
*/
1446-
constructor(mediatorName, viewComponent = null) {
1445+
constructor(mediatorName = null, viewComponent = null) {
14471446
super();
14481447
this._mediatorName = mediatorName || Mediator.NAME;
14491448
this._viewComponent = viewComponent;
@@ -1504,7 +1503,7 @@ class Mediator extends Notifier {
15041503
* be defined in the subclass that casts the view
15051504
* object to a type, like this:</P>
15061505
*
1507-
* @returns {Object}
1506+
* @returns {Object | null}
15081507
*/
15091508
get viewComponent() {
15101509
return this._viewComponent;
@@ -1566,16 +1565,16 @@ class Proxy extends Notifier {
15661565
* Constructor
15671566
*
15681567
* @constructor
1569-
* @param {string} proxyName
1570-
* @param {Object} [data]
1568+
* @param {string | null} [proxyName=null]
1569+
* @param {Object | null} [data=null]
15711570
*/
1572-
constructor(proxyName, data = null) {
1571+
constructor(proxyName = null, data = null) {
15731572
super();
15741573
/** @protected
15751574
* @type {string} */
15761575
this._proxyName = proxyName || Proxy.NAME;
15771576
/** @protected
1578-
* @type {Object} */
1577+
* @type {Object | null} */
15791578
this._data = data;
15801579
}
15811580

@@ -1601,7 +1600,7 @@ class Proxy extends Notifier {
16011600
/**
16021601
* Get the data object
16031602
*
1604-
* @returns {Object}
1603+
* @returns {Object | null}
16051604
*/
16061605
get data () {
16071606
return this._data;

bin/cjs/index.min.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";class t{constructor(t=null,e=null){this._notifyMethod=t,this._notifyContext=e}notifyObserver(t){this._notifyMethod.call(this._notifyContext,t)}compareNotifyContext(t){return this._notifyContext===t}get notifyMethod(){return this._notifyMethod}set notifyMethod(t){this._notifyMethod=t}get notifyContext(){return this._notifyContext}set notifyContext(t){this._notifyContext=t}}class e{constructor(t){if(null!=e.instanceMap.get(t))throw new Error(e.MULTITON_MSG);this.multitonKey=t,e.instanceMap.set(this.multitonKey,this),this.mediatorMap=new Map,this.observerMap=new Map,this.initializeView()}initializeView(){}static getInstance(t,i){return null==e.instanceMap&&(e.instanceMap=new Map),null==e.instanceMap.get(t)&&e.instanceMap.set(t,i(t)),e.instanceMap.get(t)}registerObserver(t,e){if(null!=this.observerMap.get(t)){this.observerMap.get(t).push(e)}else this.observerMap.set(t,new Array(e))}notifyObservers(t){if(this.observerMap.has(t.name)){let e=this.observerMap.get(t.name).slice();for(let i=0;i<e.length;i++)e[i].notifyObserver(t)}}removeObserver(t,e){let i=this.observerMap.get(t);for(let t=0;t<i.length;t++)if(!0===i[t].compareNotifyContext(e)){i.splice(t,1);break}0===i.length&&this.observerMap.delete(t)}registerMediator(e){if(!1!==this.mediatorMap.has(e.mediatorName))return;e.initializeNotifier(this.multitonKey),this.mediatorMap.set(e.mediatorName,e);let i=e.listNotificationInterests();if(i.length>0){let n=new t(e.handleNotification.bind(e),e);for(let t=0;t<i.length;t++)this.registerObserver(i[t],n)}e.onRegister()}retrieveMediator(t){return this.mediatorMap.get(t)||null}removeMediator(t){let e=this.mediatorMap.get(t);if(e){let i=e.listNotificationInterests();for(let t=0;t<i.length;t++)this.removeObserver(i[t],e);this.mediatorMap.delete(t),e.onRemove()}return e}hasMediator(t){return this.mediatorMap.has(t)}static removeView(t){this.instanceMap.delete(t)}static get MULTITON_MSG(){return"View instance for this Multiton key already constructed!"}}class i{constructor(t){if(null!=i.instanceMap[t])throw new Error(i.MULTITON_MSG);this.multitonKey=t,i.instanceMap.set(this.multitonKey,this),this.commandMap=new Map,this.initializeController()}initializeController(){this.view=e.getInstance(this.multitonKey,(t=>new e(t)))}static getInstance(t,e){return null==i.instanceMap&&(i.instanceMap=new Map),null==i.instanceMap.get(t)&&i.instanceMap.set(t,e(t)),i.instanceMap.get(t)}executeCommand(t){let e=this.commandMap.get(t.name);if(null==e)return;let i=e();i.initializeNotifier(this.multitonKey),i.execute(t)}registerCommand(e,i){null==this.commandMap.get(e)&&this.view.registerObserver(e,new t(this.executeCommand,this)),this.commandMap.set(e,i)}hasCommand(t){return this.commandMap.has(t)}removeCommand(t){this.hasCommand(t)&&(this.view.removeObserver(t,this),this.commandMap.delete(t))}static removeController(t){i.instanceMap.delete(t)}static get MULTITON_MSG(){return"Controller instance for this Multiton key already constructed!"}}class n{constructor(t){if(null!=n.instanceMap.get(t))throw new Error(n.MULTITON_MSG);this.multitonKey=t,n.instanceMap.set(this.multitonKey,this),this.proxyMap=new Map,this.initializeModel()}initializeModel(){}static getInstance(t,e){return null==n.instanceMap&&(n.instanceMap=new Map),null==n.instanceMap.get(t)&&n.instanceMap.set(t,e(t)),n.instanceMap.get(t)}registerProxy(t){t.initializeNotifier(this.multitonKey),this.proxyMap.set(t.proxyName,t),t.onRegister()}retrieveProxy(t){return this.proxyMap.get(t)||null}hasProxy(t){return this.proxyMap.has(t)}removeProxy(t){let e=this.proxyMap.get(t);return null!=e&&(this.proxyMap.delete(t),e.onRemove()),e}static removeModel(t){n.instanceMap.delete(t)}static get MULTITON_MSG(){return"Model instance for this Multiton key already constructed!"}}class r{constructor(t,e=null,i=""){this._name=t,this._body=e,this._type=i}get name(){return this._name}get body(){return this._body}set body(t){this._body=t}get type(){return this._type}set type(t){this._type=t}toString(){let t="Notification Name: "+this.name;return t+="\nBody:"+(null==this.body?"null":this.body.toString()),t+="\nType:"+(null==this.type?"null":this.type),t}}class s{constructor(t){if(null!=s.instanceMap[t])throw new Error(s.MULTITON_MSG);this.initializeNotifier(t),s.instanceMap.set(this.multitonKey,this),this.initializeFacade()}initializeFacade(){this.initializeModel(),this.initializeController(),this.initializeView()}static getInstance(t,e){return null==s.instanceMap&&(s.instanceMap=new Map),null==s.instanceMap.get(t)&&s.instanceMap.set(t,e(t)),s.instanceMap.get(t)}initializeModel(){null==this.model&&(this.model=n.getInstance(this.multitonKey,(t=>new n(t))))}initializeController(){null==this.controller&&(this.controller=i.getInstance(this.multitonKey,(t=>new i(t))))}initializeView(){null==this.view&&(this.view=e.getInstance(this.multitonKey,(t=>new e(t))))}registerCommand(t,e){this.controller.registerCommand(t,e)}hasCommand(t){return this.controller.hasCommand(t)}removeCommand(t){this.controller.removeCommand(t)}registerProxy(t){this.model.registerProxy(t)}removeProxy(t){return this.model.removeProxy(t)}hasProxy(t){return this.model.hasProxy(t)}retrieveProxy(t){return this.model.retrieveProxy(t)}registerMediator(t){this.view.registerMediator(t)}removeMediator(t){return this.view.removeMediator(t)}hasMediator(t){return this.view.hasMediator(t)}retrieveMediator(t){return this.view.retrieveMediator(t)}sendNotification(t,e=null,i=""){this.notifyObservers(new r(t,e,i))}notifyObservers(t){this.view.notifyObservers(t)}initializeNotifier(t){this.multitonKey=t}static hasCore(t){return this.instanceMap.has(t)}static removeCore(t){null!=s.instanceMap.get(t)&&(n.removeModel(t),e.removeView(t),i.removeController(t),this.instanceMap.delete(t))}static get MULTITON_MSG(){return"Facade instance for this Multiton key already constructed!"}}class o{constructor(){}sendNotification(t,e=null,i=""){null!=this.facade&&this.facade.sendNotification(t,e,i)}initializeNotifier(t){this.multitonKey=t}get facade(){if(null==this.multitonKey)throw new Error(o.MULTITON_MSG);return s.getInstance(this.multitonKey,(t=>new s(t)))}static get MULTITON_MSG(){return"multitonKey for this Notifier not yet initialized!"}}class a extends o{constructor(){super()}execute(t){}}class l extends o{constructor(t=null,e=null){super(),this._mediatorName=t||l.NAME,this._viewComponent=e}onRegister(){}onRemove(){}listNotificationInterests(){return[]}handleNotification(t){}get mediatorName(){return this._mediatorName}get viewComponent(){return this._viewComponent}set viewComponent(t){this._viewComponent=t}static get NAME(){return"Mediator"}}class h extends o{constructor(t=null,e=null){super(),this._proxyName=t||h.NAME,this._data=e}onRegister(){}onRemove(){}get proxyName(){return this._proxyName}get data(){return this._data}set data(t){this._data=t}static get NAME(){return"Proxy"}}exports.Controller=i,exports.Facade=s,exports.MacroCommand=class extends a{constructor(){super(),this.subCommands=[],this.initializeMacroCommand()}initializeMacroCommand(){}addSubCommand(t){this.subCommands.push(t)}execute(t){for(;this.subCommands.length>0;){let e=this.subCommands.shift()();e.initializeNotifier(this.multitonKey),e.execute(t)}}},exports.Mediator=l,exports.Model=n,exports.Notification=r,exports.Notifier=o,exports.Observer=t,exports.Proxy=h,exports.SimpleCommand=a,exports.View=e;
2+
//# sourceMappingURL=index.min.cjs.map

bin/cjs/index.min.cjs.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/cjs/puremvc.min.cjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/cjs/puremvc.min.cjs.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)