@quenty/observablecollection 12.11.1 → 12.12.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 +27 -0
- package/package.json +10 -9
- package/src/Shared/ObservableCountingMap.lua +9 -0
- package/src/Shared/ObservableList.lua +37 -28
- package/src/Shared/ObservableMap.lua +10 -0
- package/src/Shared/ObservableSet.lua +9 -0
- package/src/Shared/SortedList/ObservableSortedList.lua +586 -0
- package/src/Shared/{ObservableSortedList.story.lua → SortedList/ObservableSortedList.story.lua} +15 -12
- package/src/Shared/{ObservableSortedList.lua → SortedList/ObservableSortedListOld.lua} +37 -74
- package/src/Shared/SortedList/ObservableSortedList_Performance.story.lua +74 -0
- package/src/Shared/SortedList/ObservableSortedList_Print.story.lua +65 -0
- package/src/Shared/SortedList/SortFunctionUtils.lua +31 -0
- package/src/Shared/SortedList/SortedNode.lua +1171 -0
- package/src/Shared/SortedList/SortedNodeValue.lua +53 -0
- package/src/Shared/Utils/ListIndexUtils.lua +39 -0
- package/test/default.project.json +1 -7
- /package/src/Shared/{ObservableSortedList.spec.lua → SortedList/ObservableSortedList.spec.lua} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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
|
+
# [12.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@12.11.1...@quenty/observablecollection@12.12.0) (2024-11-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Apparently working list ([e7a19a7](https://github.com/Quenty/NevermoreEngine/commit/e7a19a75cc06cd8df27768b89839a0b5c91d0c46))
|
|
12
|
+
* Fix some state issues and improve performance ([69305a7](https://github.com/Quenty/NevermoreEngine/commit/69305a7732218a28c70d8e081238974b45da95e1))
|
|
13
|
+
* Slightly cleaner code ([d0a9822](https://github.com/Quenty/NevermoreEngine/commit/d0a98220429dba24b67bbccd70fa9d90a11ac793))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* Add __iter implementations ([dd6db9a](https://github.com/Quenty/NevermoreEngine/commit/dd6db9a27c98afb4177ea950f1b3e2b22d4487d2))
|
|
19
|
+
* Add unfinished observable sorted list ([c7e9817](https://github.com/Quenty/NevermoreEngine/commit/c7e9817f07c9431e5f7cdf1fa2e700d3b3277f60))
|
|
20
|
+
* Broken observable list ([4f8a551](https://github.com/Quenty/NevermoreEngine/commit/4f8a551b5b1ca6ca5bc9fd9f471ab26aeefc28f9))
|
|
21
|
+
* More stuff broken, but it's getting there ([d141e80](https://github.com/Quenty/NevermoreEngine/commit/d141e8007d789f47766b9ab98eebda864142a1ae))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Performance Improvements
|
|
25
|
+
|
|
26
|
+
* Improve iteration perf ([40ebb7a](https://github.com/Quenty/NevermoreEngine/commit/40ebb7aeea5d3f6d5e292567e023638ff8f45864))
|
|
27
|
+
* Use ObservableSubscriptionTable and stop debug validating integrity ([9d8e66b](https://github.com/Quenty/NevermoreEngine/commit/9d8e66b73b25f6ed087cbb38341bb9ea4a1162b4))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [12.11.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@12.11.0...@quenty/observablecollection@12.11.1) (2024-11-04)
|
|
7
34
|
|
|
8
35
|
**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": "12.
|
|
3
|
+
"version": "12.12.0",
|
|
4
4
|
"description": "A set of observable collections, such as sets, maps, sorted lists, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,22 +28,23 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@quenty/baseobject": "^10.7.1",
|
|
31
|
-
"@quenty/brio": "^14.
|
|
31
|
+
"@quenty/brio": "^14.12.0",
|
|
32
32
|
"@quenty/ducktype": "^5.7.1",
|
|
33
33
|
"@quenty/loader": "^10.7.1",
|
|
34
34
|
"@quenty/maid": "^3.4.0",
|
|
35
|
-
"@quenty/promise": "^10.
|
|
36
|
-
"@quenty/rx": "^13.
|
|
37
|
-
"@quenty/signal": "^7.
|
|
35
|
+
"@quenty/promise": "^10.8.0",
|
|
36
|
+
"@quenty/rx": "^13.12.0",
|
|
37
|
+
"@quenty/signal": "^7.9.0",
|
|
38
38
|
"@quenty/steputils": "^3.5.2",
|
|
39
|
-
"@quenty/symbol": "^3.
|
|
40
|
-
"@quenty/
|
|
39
|
+
"@quenty/symbol": "^3.3.0",
|
|
40
|
+
"@quenty/table": "^3.6.0",
|
|
41
|
+
"@quenty/valueobject": "^13.12.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@quenty/blend": "^12.
|
|
44
|
+
"@quenty/blend": "^12.12.0"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "00e6f71716216dd6ecbc8505ad898a1ab7f72756"
|
|
49
50
|
}
|
|
@@ -73,6 +73,15 @@ function ObservableCountingMap.isObservableMap(value)
|
|
|
73
73
|
return DuckTypeUtils.isImplementation(ObservableCountingMap, value)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
--[=[
|
|
77
|
+
Allows iteration over the observable counting map
|
|
78
|
+
|
|
79
|
+
@return (T) -> ((T, nextIndex: any) -> ...any, T?)
|
|
80
|
+
]=]
|
|
81
|
+
function ObservableCountingMap:__iter()
|
|
82
|
+
return pairs(self._map)
|
|
83
|
+
end
|
|
84
|
+
|
|
76
85
|
--[=[
|
|
77
86
|
Observes the current set of active keys
|
|
78
87
|
@return Observable<{ T }>
|
|
@@ -9,12 +9,12 @@ local Brio = require("Brio")
|
|
|
9
9
|
local Maid = require("Maid")
|
|
10
10
|
local Observable = require("Observable")
|
|
11
11
|
local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
|
|
12
|
-
local Rx = require("Rx")
|
|
13
12
|
local RxBrioUtils = require("RxBrioUtils")
|
|
14
13
|
local Signal = require("Signal")
|
|
15
14
|
local Symbol = require("Symbol")
|
|
16
15
|
local ValueObject = require("ValueObject")
|
|
17
16
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
17
|
+
local ListIndexUtils = require("ListIndexUtils")
|
|
18
18
|
|
|
19
19
|
local ObservableList = {}
|
|
20
20
|
ObservableList.ClassName = "ObservableList"
|
|
@@ -78,15 +78,38 @@ end
|
|
|
78
78
|
@return Observable<{ T }>
|
|
79
79
|
]=]
|
|
80
80
|
function ObservableList:Observe()
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
return Observable.new(function(sub)
|
|
82
|
+
local maid = Maid.new()
|
|
83
|
+
|
|
84
|
+
local function queueFire()
|
|
85
|
+
if maid._queue then
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
maid._queue = task.defer(function()
|
|
90
|
+
maid._queue = nil
|
|
91
|
+
sub:Fire(self:GetList())
|
|
92
|
+
end)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
maid:GiveTask(self.ItemAdded:Connect(queueFire))
|
|
96
|
+
maid:GiveTask(self.ItemRemoved:Connect(queueFire))
|
|
97
|
+
|
|
98
|
+
return maid
|
|
99
|
+
end)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
--[=[
|
|
103
|
+
Allows iteration over the observable map
|
|
104
|
+
|
|
105
|
+
@return (T) -> ((T, nextIndex: any) -> ...any, T?)
|
|
106
|
+
]=]
|
|
107
|
+
function ObservableList:__iter()
|
|
108
|
+
return coroutine.wrap(function()
|
|
109
|
+
for index, value in self._keyList do
|
|
110
|
+
coroutine.yield(index, self._contents[value])
|
|
111
|
+
end
|
|
112
|
+
end)
|
|
90
113
|
end
|
|
91
114
|
|
|
92
115
|
--[=[
|
|
@@ -265,7 +288,7 @@ end
|
|
|
265
288
|
function ObservableList:Get(index)
|
|
266
289
|
assert(type(index) == "number", "Bad index")
|
|
267
290
|
|
|
268
|
-
index = self
|
|
291
|
+
index = ListIndexUtils.toPositiveIndex(#self._keyList, index)
|
|
269
292
|
|
|
270
293
|
local key = self._keyList[index]
|
|
271
294
|
if not key then
|
|
@@ -319,12 +342,12 @@ function ObservableList:InsertAt(item, index)
|
|
|
319
342
|
-- Fire off the index change on the value
|
|
320
343
|
self._keyIndexObservables:Fire(key, index)
|
|
321
344
|
self._indexObservers:Fire(index, item)
|
|
322
|
-
self._indexObservers:Fire(
|
|
345
|
+
self._indexObservers:Fire(ListIndexUtils.toNegativeIndex(listLength, index), item)
|
|
323
346
|
|
|
324
347
|
for _, data in pairs(changed) do
|
|
325
348
|
if self._indexes[data.key] == data.newIndex then
|
|
326
349
|
self._indexObservers:Fire(data.newIndex, self._contents[data.key])
|
|
327
|
-
self._indexObservers:Fire(
|
|
350
|
+
self._indexObservers:Fire(ListIndexUtils.toNegativeIndex(listLength, index), self._contents[data.key])
|
|
328
351
|
self._keyIndexObservables:Fire(data.key, data.newIndex)
|
|
329
352
|
end
|
|
330
353
|
end
|
|
@@ -409,7 +432,7 @@ function ObservableList:RemoveByKey(key)
|
|
|
409
432
|
for _, data in pairs(changed) do
|
|
410
433
|
if self._indexes[data.key] == data.newIndex then
|
|
411
434
|
self._indexObservers:Fire(data.newIndex, self._contents[data.key])
|
|
412
|
-
self._indexObservers:Fire(
|
|
435
|
+
self._indexObservers:Fire(ListIndexUtils.toNegativeIndex(listLength, index), self._contents[data.key])
|
|
413
436
|
self._keyIndexObservables:Fire(data.key, data.newIndex)
|
|
414
437
|
end
|
|
415
438
|
end
|
|
@@ -429,20 +452,6 @@ function ObservableList:GetList()
|
|
|
429
452
|
return list
|
|
430
453
|
end
|
|
431
454
|
|
|
432
|
-
function ObservableList:_toPositiveIndex(index)
|
|
433
|
-
if index > 0 then
|
|
434
|
-
return index
|
|
435
|
-
elseif index < 0 then
|
|
436
|
-
return #self._keyList + index + 1
|
|
437
|
-
else
|
|
438
|
-
error(string.format("[ObservableList._toPositiveIndex] - Bad index %d", index))
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
function ObservableList:_toNegativeIndex(listLength, index)
|
|
443
|
-
return -listLength + index - 1
|
|
444
|
-
end
|
|
445
|
-
|
|
446
455
|
--[=[
|
|
447
456
|
Cleans up the ObservableList and sets the metatable to nil.
|
|
448
457
|
]=]
|
|
@@ -74,6 +74,16 @@ function ObservableMap.isObservableMap(value)
|
|
|
74
74
|
return DuckTypeUtils.isImplementation(ObservableMap, value)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
--[=[
|
|
78
|
+
Allows iteration over the observable map
|
|
79
|
+
|
|
80
|
+
@return (T) -> ((T, nextIndex: any) -> ...any, T?)
|
|
81
|
+
]=]
|
|
82
|
+
function ObservableMap:__iter()
|
|
83
|
+
return pairs(self._map)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
|
|
77
87
|
--[=[
|
|
78
88
|
Observes all keys in the map
|
|
79
89
|
@return Observable<Brio<TKey>>
|
|
@@ -65,6 +65,15 @@ function ObservableSet.isObservableSet(value)
|
|
|
65
65
|
return DuckTypeUtils.isImplementation(ObservableSet, value)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
--[=[
|
|
69
|
+
Allows iteration over the observable set
|
|
70
|
+
|
|
71
|
+
@return (T) -> ((T, nextIndex: any) -> ...any, T?)
|
|
72
|
+
]=]
|
|
73
|
+
function ObservableSet:__iter()
|
|
74
|
+
return pairs(self._set)
|
|
75
|
+
end
|
|
76
|
+
|
|
68
77
|
--[=[
|
|
69
78
|
Observes all items in the set
|
|
70
79
|
@return Observable<Brio<T>>
|