@quenty/servicebag 7.0.0 → 7.1.0
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/CHANGELOG.md +11 -0
- package/package.json +5 -5
- package/src/Shared/ServiceBag.lua +26 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/servicebag@7.0.0...@quenty/servicebag@7.1.0) (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add service bag destruction errors that are more clear ([0d3087e](https://github.com/Quenty/NevermoreEngine/commit/0d3087efbf67c047839aa062496ed7d09fa8da69))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/servicebag@6.9.0...@quenty/servicebag@7.0.0) (2023-10-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/servicebag
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/servicebag",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Service providing mechanisms for Nevermore",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/baseobject": "^7.
|
|
30
|
-
"@quenty/loader": "^7.
|
|
31
|
-
"@quenty/signal": "^3.
|
|
29
|
+
"@quenty/baseobject": "^7.1.0",
|
|
30
|
+
"@quenty/loader": "^7.1.0",
|
|
31
|
+
"@quenty/signal": "^3.1.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "2c2dbbc0cb2fbb46b4f3270c559c63890fe18b26"
|
|
37
37
|
}
|
|
@@ -59,11 +59,11 @@ function ServiceBag.new(parentProvider)
|
|
|
59
59
|
self._serviceTypesToInitializeSet = {}
|
|
60
60
|
self._initializedServiceTypeSet = {}
|
|
61
61
|
self._initializing = false
|
|
62
|
+
self._destructing = false
|
|
62
63
|
|
|
63
64
|
self._serviceTypesToStart = {}
|
|
64
65
|
|
|
65
|
-
self.
|
|
66
|
-
self._maid:GiveTask(self._destroying)
|
|
66
|
+
self._destroyingSignal = Signal.new()
|
|
67
67
|
|
|
68
68
|
return self
|
|
69
69
|
end
|
|
@@ -168,7 +168,7 @@ function ServiceBag:Start()
|
|
|
168
168
|
|
|
169
169
|
local isDead = coroutine.status(current) == "dead"
|
|
170
170
|
if not isDead then
|
|
171
|
-
error(("Starting service %q yielded"
|
|
171
|
+
error(string.format("Starting service %q yielded", serviceName))
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
end
|
|
@@ -208,7 +208,7 @@ function ServiceBag:CreateScope()
|
|
|
208
208
|
self:_addServiceType(provider)
|
|
209
209
|
|
|
210
210
|
-- Remove from parent provider
|
|
211
|
-
self._maid[provider] = provider.
|
|
211
|
+
self._maid[provider] = provider._destroyingSignal:Connect(function()
|
|
212
212
|
self._maid[provider] = nil
|
|
213
213
|
self._services[provider] = nil
|
|
214
214
|
end)
|
|
@@ -218,8 +218,14 @@ end
|
|
|
218
218
|
|
|
219
219
|
-- Adds a service to this provider only
|
|
220
220
|
function ServiceBag:_addServiceType(serviceType)
|
|
221
|
+
if self._destructing then
|
|
222
|
+
local serviceName = self:_getServiceName(serviceType)
|
|
223
|
+
error(string.format("Cannot query service %q after ServiceBag is cleaned up", serviceName))
|
|
224
|
+
return
|
|
225
|
+
end
|
|
226
|
+
|
|
221
227
|
if not self._serviceTypesToInitializeSet then
|
|
222
|
-
error(("Already finished initializing, cannot add %q"
|
|
228
|
+
error(string.format("Already finished initializing, cannot add %q", self:_getServiceName(serviceType)))
|
|
223
229
|
return
|
|
224
230
|
end
|
|
225
231
|
|
|
@@ -240,6 +246,12 @@ function ServiceBag:_ensureInitialization(serviceType)
|
|
|
240
246
|
return
|
|
241
247
|
end
|
|
242
248
|
|
|
249
|
+
if self._destructing then
|
|
250
|
+
local serviceName = self:_getServiceName(serviceType)
|
|
251
|
+
error(string.format("Cannot initialize service %q after ServiceBag is cleaned up", serviceName))
|
|
252
|
+
return
|
|
253
|
+
end
|
|
254
|
+
|
|
243
255
|
if self._initializing then
|
|
244
256
|
self._serviceTypesToInitializeSet[serviceType] = nil
|
|
245
257
|
self._initializedServiceTypeSet[serviceType] = true
|
|
@@ -266,7 +278,7 @@ function ServiceBag:_initService(serviceType)
|
|
|
266
278
|
|
|
267
279
|
local isDead = coroutine.status(current) == "dead"
|
|
268
280
|
if not isDead then
|
|
269
|
-
error(("Initializing service %q yielded"
|
|
281
|
+
error(string.format("Initializing service %q yielded", serviceName))
|
|
270
282
|
end
|
|
271
283
|
end
|
|
272
284
|
|
|
@@ -278,9 +290,16 @@ end
|
|
|
278
290
|
initialized in the service bag.
|
|
279
291
|
]=]
|
|
280
292
|
function ServiceBag:Destroy()
|
|
293
|
+
if self._destructing then
|
|
294
|
+
return
|
|
295
|
+
end
|
|
296
|
+
|
|
281
297
|
local super = getmetatable(ServiceBag)
|
|
282
298
|
|
|
283
|
-
self.
|
|
299
|
+
self._destructing = true
|
|
300
|
+
|
|
301
|
+
self._destroyingSignal:Fire()
|
|
302
|
+
self._destroyingSignal:Destroy()
|
|
284
303
|
|
|
285
304
|
local services = self._services
|
|
286
305
|
local key, service = next(services)
|