Permalink
Browse files

always call "configure" method of the singleton instance (even on 1st…

… access to it)
  • Loading branch information...
1 parent 8410ab7 commit 1fd97076fe529017ddf50a82e890af1c5c833e8a @SamuraiJack SamuraiJack committed Apr 5, 2017
Showing with 17 additions and 18 deletions.
  1. +17 −18 lib/Joose/Meta/Singleton.js
@@ -1,42 +1,41 @@
Role('Joose.Meta.Singleton', {
-
+
has : {
forceInstance : Joose.I.Object,
instance : null
},
-
-
-
+
+
+
override : {
-
+
defaultConstructor : function () {
var meta = this
var previous = this.SUPER()
-
+
this.adaptConstructor(previous)
-
+
return function (forceInstance, params) {
if (forceInstance == meta.forceInstance) return previous.apply(this, params) || this
-
+
var instance = meta.instance
-
- if (instance) {
- if (meta.hasMethod('configure')) instance.configure.apply(instance, arguments)
- } else
- meta.instance = new meta.c(meta.forceInstance, arguments)
-
- return meta.instance
+
+ if (!instance) instance = meta.instance = new meta.c(meta.forceInstance, arguments)
+
+ if (meta.hasMethod('configure')) instance.configure.apply(instance, arguments)
+
+ return instance
}
- }
+ }
}
-
+
})
Joose.Namespace.Manager.my.register('Singleton', Class({
isa : Joose.Meta.Class,
meta : Joose.Meta.Class,
-
+
does : Joose.Meta.Singleton
}))

0 comments on commit 1fd9707

Please sign in to comment.