@quenty/datastore 5.2.0 → 5.2.1-canary.276.672e37b.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
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
## [5.2.1-canary.276.672e37b.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@5.2.0...@quenty/datastore@5.2.1-canary.276.672e37b.0) (2022-07-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add GameDataStoreService service for global game data ([5f6d52c](https://github.com/Quenty/NevermoreEngine/commit/5f6d52ca9f2be811c426714cd6d94d9794f366b5))
|
|
12
|
+
* Support StoreOnValueChange with non ValueBase instances. ([ab45498](https://github.com/Quenty/NevermoreEngine/commit/ab4549833f41f2b3d8b43202965fd3202b649770))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [5.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@5.1.0...@quenty/datastore@5.2.0) (2022-07-02)
|
|
7
19
|
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/datastore",
|
|
3
|
-
"version": "5.2.0",
|
|
3
|
+
"version": "5.2.1-canary.276.672e37b.0",
|
|
4
4
|
"description": "Quenty's Datastore implementation for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/baseobject": "
|
|
30
|
-
"@quenty/loader": "
|
|
31
|
-
"@quenty/maid": "
|
|
32
|
-
"@quenty/promise": "
|
|
33
|
-
"@quenty/signal": "
|
|
34
|
-
"@quenty/symbol": "
|
|
35
|
-
"@quenty/table": "
|
|
29
|
+
"@quenty/baseobject": "5.0.1-canary.276.672e37b.0",
|
|
30
|
+
"@quenty/loader": "5.0.0",
|
|
31
|
+
"@quenty/maid": "2.3.1-canary.276.672e37b.0",
|
|
32
|
+
"@quenty/promise": "5.0.1-canary.276.672e37b.0",
|
|
33
|
+
"@quenty/signal": "2.2.0",
|
|
34
|
+
"@quenty/symbol": "2.1.0",
|
|
35
|
+
"@quenty/table": "3.1.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "672e37b9bbb8b2d4c4c6c69ed2647335be0bc469"
|
|
41
41
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Service which manages central access to datastore. This datastore will refresh pretty frequently and
|
|
3
|
+
can be used for configuration and other components, such as Twitter codes or global settings.
|
|
4
|
+
|
|
5
|
+
@class GameDataStoreService
|
|
6
|
+
]=]
|
|
7
|
+
|
|
8
|
+
local require = require(script.Parent.loader).load(script)
|
|
9
|
+
|
|
10
|
+
local RunService = game:GetService("RunService")
|
|
11
|
+
|
|
12
|
+
local DataStore = require("DataStore")
|
|
13
|
+
local DataStorePromises = require("DataStorePromises")
|
|
14
|
+
local Maid = require("Maid")
|
|
15
|
+
|
|
16
|
+
local GameDataStoreService = {}
|
|
17
|
+
|
|
18
|
+
function GameDataStoreService:Init(serviceBag)
|
|
19
|
+
assert(not self._serviceBag, "Already initialized")
|
|
20
|
+
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
21
|
+
|
|
22
|
+
self._maid = Maid.new()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
--[=[
|
|
26
|
+
For if you want to disable saving in studio for faster close time!
|
|
27
|
+
]=]
|
|
28
|
+
function GameDataStoreService:DisableSaveOnCloseStudio()
|
|
29
|
+
assert(RunService:IsStudio())
|
|
30
|
+
|
|
31
|
+
self._disableSavingInStudio = true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
function GameDataStoreService:Start()
|
|
35
|
+
game:BindToClose(function()
|
|
36
|
+
if self._disableSavingInStudio then
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
return self:PromiseDataStore()
|
|
41
|
+
:Then(function(dataStore)
|
|
42
|
+
return dataStore:Save()
|
|
43
|
+
end)
|
|
44
|
+
:Wait()
|
|
45
|
+
end)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
function GameDataStoreService:PromiseDataStore()
|
|
49
|
+
if self._dataStorePromise then
|
|
50
|
+
return self._dataStorePromise
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
self._dataStorePromise = self:_promiseRobloxDataStore()
|
|
54
|
+
:Then(function(robloxDataStore)
|
|
55
|
+
local dataStore = DataStore.new(robloxDataStore, self:_getKey())
|
|
56
|
+
self._maid._datastore = dataStore
|
|
57
|
+
|
|
58
|
+
return dataStore
|
|
59
|
+
end)
|
|
60
|
+
|
|
61
|
+
return self._dataStorePromise
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
function GameDataStoreService:_promiseRobloxDataStore()
|
|
65
|
+
if self._robloxDataStorePromise then
|
|
66
|
+
return self._robloxDataStorePromise
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
self._robloxDataStorePromise = self._maid:GivePromise(DataStorePromises.promiseDataStore("GameDataStore", "Version1"))
|
|
70
|
+
|
|
71
|
+
return self._robloxDataStorePromise
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
function GameDataStoreService:_getKey()
|
|
75
|
+
return "version1"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
function GameDataStoreService:Destroy()
|
|
79
|
+
self._maid:DoCleaning()
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
return GameDataStoreService
|
|
@@ -245,7 +245,7 @@ end
|
|
|
245
245
|
]=]
|
|
246
246
|
function DataStoreStage:StoreOnValueChange(name, valueObj)
|
|
247
247
|
assert(type(name) == "string", "Bad name")
|
|
248
|
-
assert(typeof(valueObj) == "Instance", "Bad valueObj")
|
|
248
|
+
assert(typeof(valueObj) == "Instance" or (type(valueObj) == "table" and valueObj.Changed), "Bad valueObj")
|
|
249
249
|
|
|
250
250
|
if self._takenKeys[name] then
|
|
251
251
|
error(("[DataStoreStage] - Already have a writer for %q"):format(name))
|