@quenty/datastore 7.25.1 → 7.25.2

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,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.25.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@7.25.1...@quenty/datastore@7.25.2) (2023-09-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Ensure default value is returned in certain nil scenarios ([f9032d0](https://github.com/Quenty/NevermoreEngine/commit/f9032d0d465231f86f55a60c6465183731567b4c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.25.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@7.25.0...@quenty/datastore@7.25.1) (2023-09-07)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/datastore",
3
- "version": "7.25.1",
3
+ "version": "7.25.2",
4
4
  "description": "Quenty's Datastore implementation for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "fe2f05c688fe7c7bb7db1f969aa46b008fda8a7f"
45
+ "gitHead": "c121b834f8241055d80d66d35be65f648babecdb"
46
46
  }
@@ -141,11 +141,16 @@ end
141
141
  end)
142
142
  ```
143
143
 
144
+ @param defaultValue any
144
145
  @return Promise<any>
145
146
  ]=]
146
- function DataStoreStage:LoadAll()
147
+ function DataStoreStage:LoadAll(defaultValue)
147
148
  return self:PromiseViewUpToDate():Then(function()
148
- return self._viewSnapshot
149
+ if self._viewSnapshot == nil then
150
+ return defaultValue
151
+ else
152
+ return self._viewSnapshot
153
+ end
149
154
  end)
150
155
  end
151
156
 
@@ -250,10 +255,18 @@ function DataStoreStage:Observe(key, defaultValue)
250
255
  :Then(function()
251
256
  -- Only connect once loaded
252
257
  maid:GiveTask(self.Changed:Connect(function(viewSnapshot)
253
- sub:Fire(viewSnapshot)
258
+ if viewSnapshot == nil then
259
+ sub:Fire(defaultValue)
260
+ else
261
+ sub:Fire(viewSnapshot)
262
+ end
254
263
  end))
255
264
 
256
- sub:Fire(self._viewSnapshot)
265
+ if self._viewSnapshot == nil then
266
+ sub:Fire(defaultValue)
267
+ else
268
+ sub:Fire(self._viewSnapshot)
269
+ end
257
270
  end, function(...)
258
271
  sub:Fail(...)
259
272
  end)
@@ -265,7 +278,13 @@ function DataStoreStage:Observe(key, defaultValue)
265
278
  return Observable.new(function(sub)
266
279
  local maid = Maid.new()
267
280
 
268
- maid:GiveTask(self._keySubscriptions:Observe(key):Subscribe(sub:GetFireFailComplete()))
281
+ maid:GiveTask(self._keySubscriptions:Observe(key):Subscribe(function(value)
282
+ if value == nil then
283
+ sub:Fire(defaultValue)
284
+ else
285
+ sub:Fire(value)
286
+ end
287
+ end), sub:GetFailComplete())
269
288
 
270
289
  -- Load initially
271
290
  maid:GivePromise(self:Load(key, defaultValue))