fable 3.0.142 → 3.0.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fable.compatible.js +1 -1
- package/dist/fable.compatible.min.js +1 -1
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +1 -1
- package/dist/fable.min.js +1 -1
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Fable.js +16 -2
- package/test/FableServiceManager_tests.js +17 -0
package/package.json
CHANGED
package/source/Fable.js
CHANGED
|
@@ -171,13 +171,27 @@ class Fable extends libFableServiceBase.CoreServiceProviderBase
|
|
|
171
171
|
{
|
|
172
172
|
this.addServiceTypeIfNotExists(pServiceType, pServiceClass);
|
|
173
173
|
|
|
174
|
-
if (!(pServiceType in this.servicesMap))
|
|
174
|
+
if ((!(pServiceType in this.servicesMap)) || (!(pServiceType in this.fable)))
|
|
175
175
|
{
|
|
176
176
|
return this.instantiateServiceProvider(pServiceType, {}, `${pServiceType}-Default`);
|
|
177
177
|
}
|
|
178
178
|
else
|
|
179
179
|
{
|
|
180
|
-
return this
|
|
180
|
+
return this[pServiceType];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
addAndInstantiateSingletonService(pServiceType, pOptions, pServiceClass)
|
|
185
|
+
{
|
|
186
|
+
this.addServiceTypeIfNotExists(pServiceType, pServiceClass);
|
|
187
|
+
|
|
188
|
+
if ((!(pServiceType in this.servicesMap)) || (!(pServiceType in this.fable)))
|
|
189
|
+
{
|
|
190
|
+
return this.instantiateServiceProvider(pServiceType, {}, `${pServiceType}-Default`);
|
|
191
|
+
}
|
|
192
|
+
else
|
|
193
|
+
{
|
|
194
|
+
return this[pServiceType];
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
|
|
@@ -166,7 +166,24 @@ suite
|
|
|
166
166
|
Expect(tmpService).to.be.an('object');
|
|
167
167
|
}
|
|
168
168
|
);
|
|
169
|
+
test
|
|
170
|
+
(
|
|
171
|
+
'Add and instantiate a singleton service',
|
|
172
|
+
function ()
|
|
173
|
+
{
|
|
174
|
+
let testFable = new libFable({});
|
|
175
|
+
|
|
176
|
+
let tmpService = testFable.addAndInstantiateSingletonService('SimpleService', {}, SimpleService);
|
|
169
177
|
|
|
178
|
+
Expect(testFable.SimpleService).to.be.an('object');
|
|
179
|
+
Expect(tmpService).to.be.an('object');
|
|
180
|
+
|
|
181
|
+
let tmpService2 = testFable.addAndInstantiateSingletonService('SimpleService', {}, SimpleService);
|
|
182
|
+
|
|
183
|
+
// A second call should not construct another one.
|
|
184
|
+
Expect(tmpService2.Hash).to.equal(tmpService.Hash);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
170
187
|
test
|
|
171
188
|
(
|
|
172
189
|
'Change the default service provider',
|