@quenty/observablecollection 5.13.0 → 5.14.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,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
+ # [5.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@5.13.0...@quenty/observablecollection@5.14.0) (2023-04-20)
7
+
8
+
9
+ ### Features
10
+
11
+ * Ensure removal is a bit more clean ([4b70f6d](https://github.com/Quenty/NevermoreEngine/commit/4b70f6d72cee9393c70b1ce17e78d8e63771ac3c))
12
+
13
+
14
+
15
+
16
+
6
17
  # [5.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@5.12.1...@quenty/observablecollection@5.13.0) (2023-04-10)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/observablecollection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/observablecollection",
3
- "version": "5.13.0",
3
+ "version": "5.14.0",
4
4
  "description": "A set of observable collections, such as sets, maps, sorted lists, and more.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "3306212248c310731931ad45d8b86dc7247f2a5d"
42
+ "gitHead": "15d1274fffdaef706f849fd5dca2f14364c1264e"
43
43
  }
@@ -216,14 +216,17 @@ end
216
216
  Adds the item to the set if it does not exists.
217
217
  @param key TKey
218
218
  @param value TValue?
219
- @return callback -- Call to remove the value.
219
+ @return callback -- Call to remove the value if it was added
220
220
  ]=]
221
221
  function ObservableMap:Set(key, value)
222
222
  assert(key ~= nil, "Bad key")
223
223
 
224
224
  local oldValue = self._map[key]
225
225
  if oldValue == value then
226
- return
226
+ -- no removal since we never added. this is a tad messy.
227
+ return function()
228
+
229
+ end
227
230
  end
228
231
 
229
232
  self._map[key] = value
@@ -249,8 +252,16 @@ function ObservableMap:Set(key, value)
249
252
  end
250
253
  end
251
254
 
255
+ return self:_getRemovalCallback(key, value)
256
+ end
257
+
258
+ function ObservableMap:_getRemovalCallback(key, value)
252
259
  return function()
253
- if self.Destroy then
260
+ if not self.Destroy then
261
+ return
262
+ end
263
+
264
+ if self._map[key] == value then
254
265
  self:Remove(key)
255
266
  end
256
267
  end