@quenty/observablecollection 12.20.2 → 12.20.3
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 +8 -0
- package/package.json +13 -13
- package/src/Shared/ObservableCountingMap.lua +7 -7
- package/src/Shared/ObservableList.lua +10 -10
- package/src/Shared/ObservableMap.lua +4 -4
- package/src/Shared/ObservableMapList.lua +106 -61
- package/src/Shared/ObservableMapSet.lua +8 -8
- package/src/Shared/ObservableSet.lua +5 -5
- package/src/Shared/SortedList/ObservableSortedList.lua +5 -5
- package/src/Shared/SortedList/SortedNode.lua +2 -2
- package/src/Shared/SortedList/SortedNodeValue.lua +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.20.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@12.20.2...@quenty/observablecollection@12.20.3) (2025-04-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/observablecollection
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [12.20.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@12.20.0...@quenty/observablecollection@12.20.2) (2025-04-07)
|
|
7
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/observablecollection",
|
|
3
|
-
"version": "12.20.
|
|
3
|
+
"version": "12.20.3",
|
|
4
4
|
"description": "A set of observable collections, such as sets, maps, sorted lists, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"Quenty"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/baseobject": "^10.8.
|
|
31
|
-
"@quenty/brio": "^14.17.
|
|
32
|
-
"@quenty/ducktype": "^5.8.
|
|
33
|
-
"@quenty/loader": "^10.8.
|
|
34
|
-
"@quenty/maid": "^3.4.
|
|
35
|
-
"@quenty/promise": "^10.10.
|
|
36
|
-
"@quenty/rx": "^13.17.
|
|
37
|
-
"@quenty/signal": "^7.10.
|
|
30
|
+
"@quenty/baseobject": "^10.8.3",
|
|
31
|
+
"@quenty/brio": "^14.17.3",
|
|
32
|
+
"@quenty/ducktype": "^5.8.4",
|
|
33
|
+
"@quenty/loader": "^10.8.3",
|
|
34
|
+
"@quenty/maid": "^3.4.3",
|
|
35
|
+
"@quenty/promise": "^10.10.4",
|
|
36
|
+
"@quenty/rx": "^13.17.3",
|
|
37
|
+
"@quenty/signal": "^7.10.3",
|
|
38
38
|
"@quenty/steputils": "^3.5.5",
|
|
39
39
|
"@quenty/symbol": "^3.4.2",
|
|
40
|
-
"@quenty/table": "^3.7.
|
|
41
|
-
"@quenty/valueobject": "^13.17.
|
|
40
|
+
"@quenty/table": "^3.7.4",
|
|
41
|
+
"@quenty/valueobject": "^13.17.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@quenty/blend": "^12.18.
|
|
44
|
+
"@quenty/blend": "^12.18.3"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b06c070ae91d5dab7bd8de6e290ad2caabb15d8f"
|
|
50
50
|
}
|
|
@@ -57,7 +57,7 @@ export type ObservableCountingMap<T> = typeof(setmetatable(
|
|
|
57
57
|
_keySubTable: any, -- ObservableSubscriptionTable.ObservableSubscriptionTable<number>,
|
|
58
58
|
_totalKeyCountValue: ValueObject.ValueObject<number>,
|
|
59
59
|
},
|
|
60
|
-
ObservableCountingMap
|
|
60
|
+
{} :: typeof({ __index = ObservableCountingMap })
|
|
61
61
|
))
|
|
62
62
|
|
|
63
63
|
--[=[
|
|
@@ -147,9 +147,9 @@ function ObservableCountingMap._observeDerivedDataStructureFromKeys<T>(
|
|
|
147
147
|
|
|
148
148
|
emit()
|
|
149
149
|
|
|
150
|
-
self._maid[sub
|
|
150
|
+
self._maid[sub] = maid
|
|
151
151
|
maid:GiveTask(function()
|
|
152
|
-
self._maid[sub
|
|
152
|
+
self._maid[sub] = nil
|
|
153
153
|
sub:Complete()
|
|
154
154
|
end)
|
|
155
155
|
|
|
@@ -184,9 +184,9 @@ function ObservableCountingMap.ObservePairsBrio<T>(
|
|
|
184
184
|
|
|
185
185
|
maid:GiveTask(self.KeyChanged:Connect(handleValue))
|
|
186
186
|
|
|
187
|
-
self._maid[sub
|
|
187
|
+
self._maid[sub] = maid
|
|
188
188
|
maid:GiveTask(function()
|
|
189
|
-
self._maid[sub
|
|
189
|
+
self._maid[sub] = nil
|
|
190
190
|
sub:Complete()
|
|
191
191
|
end)
|
|
192
192
|
|
|
@@ -237,9 +237,9 @@ function ObservableCountingMap.ObserveKeysBrio<T>(self: ObservableCountingMap<T>
|
|
|
237
237
|
handleItem(key)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
-
self._maid[sub
|
|
240
|
+
self._maid[sub] = maid
|
|
241
241
|
maid:GiveTask(function()
|
|
242
|
-
self._maid[sub
|
|
242
|
+
self._maid[sub] = nil
|
|
243
243
|
sub:Complete()
|
|
244
244
|
end)
|
|
245
245
|
|
|
@@ -28,8 +28,8 @@ export type ObservableList<T> = typeof(setmetatable(
|
|
|
28
28
|
_keyList: { Symbol.Symbol },
|
|
29
29
|
_contents: { [Symbol.Symbol]: T },
|
|
30
30
|
_indexes: { [Symbol.Symbol]: number },
|
|
31
|
-
_indexObservers: ObservableSubscriptionTable.ObservableSubscriptionTable<T?>,
|
|
32
|
-
_keyIndexObservables: ObservableSubscriptionTable.ObservableSubscriptionTable<number?>,
|
|
31
|
+
_indexObservers: any; -- ObservableSubscriptionTable.ObservableSubscriptionTable<T?>,
|
|
32
|
+
_keyIndexObservables: any; -- ObservableSubscriptionTable.ObservableSubscriptionTable<number?>,
|
|
33
33
|
_countValue: ValueObject.ValueObject<number>,
|
|
34
34
|
|
|
35
35
|
--[=[
|
|
@@ -55,7 +55,7 @@ export type ObservableList<T> = typeof(setmetatable(
|
|
|
55
55
|
]=]
|
|
56
56
|
CountChanged: Signal.Signal<number>,
|
|
57
57
|
},
|
|
58
|
-
ObservableList
|
|
58
|
+
{} :: typeof({ __index = ObservableList })
|
|
59
59
|
))
|
|
60
60
|
|
|
61
61
|
--[=[
|
|
@@ -63,7 +63,7 @@ export type ObservableList<T> = typeof(setmetatable(
|
|
|
63
63
|
@return ObservableList<T>
|
|
64
64
|
]=]
|
|
65
65
|
function ObservableList.new<T>(): ObservableList<T>
|
|
66
|
-
local self = setmetatable({}, ObservableList)
|
|
66
|
+
local self: ObservableList<T> = setmetatable({} :: any, ObservableList)
|
|
67
67
|
|
|
68
68
|
self._maid = Maid.new()
|
|
69
69
|
|
|
@@ -75,11 +75,11 @@ function ObservableList.new<T>(): ObservableList<T>
|
|
|
75
75
|
self._keyIndexObservables = self._maid:Add(ObservableSubscriptionTable.new())
|
|
76
76
|
self._countValue = self._maid:Add(ValueObject.new(0, "number"))
|
|
77
77
|
|
|
78
|
-
self.ItemAdded = self._maid:Add(Signal.new())
|
|
79
|
-
self.ItemRemoved = self._maid:Add(Signal.new())
|
|
80
|
-
self.CountChanged = self._countValue.Changed
|
|
78
|
+
self.ItemAdded = self._maid:Add(Signal.new() :: any)
|
|
79
|
+
self.ItemRemoved = self._maid:Add(Signal.new() :: any)
|
|
80
|
+
self.CountChanged = self._countValue.Changed :: any
|
|
81
81
|
|
|
82
|
-
return self
|
|
82
|
+
return self
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
--[=[
|
|
@@ -154,9 +154,9 @@ function ObservableList.ObserveItemsBrio<T>(self: ObservableList<T>): Observable
|
|
|
154
154
|
handleItem(self._contents[key], index, key)
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
self._maid[sub
|
|
157
|
+
self._maid[sub] = maid
|
|
158
158
|
maid:GiveTask(function()
|
|
159
|
-
self._maid[sub
|
|
159
|
+
self._maid[sub] = nil
|
|
160
160
|
sub:Complete()
|
|
161
161
|
end)
|
|
162
162
|
|
|
@@ -58,7 +58,7 @@ export type ObservableMap<TKey, TValue> = typeof(setmetatable(
|
|
|
58
58
|
]=]
|
|
59
59
|
CountChanged: Signal.Signal<number>,
|
|
60
60
|
},
|
|
61
|
-
ObservableMap
|
|
61
|
+
{} :: typeof({ __index = ObservableMap })
|
|
62
62
|
))
|
|
63
63
|
|
|
64
64
|
--[=[
|
|
@@ -129,7 +129,7 @@ function ObservableMap.ObservePairsBrio<TKey, TValue>(
|
|
|
129
129
|
): Observable.Observable<Brio.Brio<(TKey, TValue)>>
|
|
130
130
|
return self:_observeKeyValueChanged(function(key: TKey, value: TValue)
|
|
131
131
|
return Brio.new(key, value)
|
|
132
|
-
end)
|
|
132
|
+
end) :: any
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
function ObservableMap._observeKeyValueChanged<TKey, TValue>(
|
|
@@ -156,12 +156,12 @@ function ObservableMap._observeKeyValueChanged<TKey, TValue>(
|
|
|
156
156
|
local conn = self.KeyValueChanged:Connect(handleValue)
|
|
157
157
|
|
|
158
158
|
local function cleanup()
|
|
159
|
-
self._maid[sub
|
|
159
|
+
self._maid[sub] = nil
|
|
160
160
|
conn:Disconnect()
|
|
161
161
|
sub:Complete()
|
|
162
162
|
maid:Destroy()
|
|
163
163
|
end
|
|
164
|
-
self._maid[sub
|
|
164
|
+
self._maid[sub] = cleanup
|
|
165
165
|
return cleanup
|
|
166
166
|
end) :: any
|
|
167
167
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Holds a map of lists. This is good for list-based
|
|
3
4
|
|
|
@@ -12,42 +13,58 @@ local ObservableList = require("ObservableList")
|
|
|
12
13
|
local ObservableMap = require("ObservableMap")
|
|
13
14
|
local Rx = require("Rx")
|
|
14
15
|
local RxBrioUtils = require("RxBrioUtils")
|
|
16
|
+
local _Signal = require("Signal")
|
|
17
|
+
local _Brio = require("Brio")
|
|
15
18
|
|
|
16
19
|
local ObservableMapList = {}
|
|
17
20
|
ObservableMapList.ClassName = "ObservableMapList"
|
|
18
21
|
ObservableMapList.__index = ObservableMapList
|
|
19
22
|
|
|
23
|
+
type ObservableList<T> = any --ObservableList.ObservableList<T>
|
|
24
|
+
|
|
25
|
+
export type ObservableMapList<TKey, TValue> = typeof(setmetatable(
|
|
26
|
+
{} :: {
|
|
27
|
+
_observableMapOfLists: any, --ObservableMap.ObservableMap<TKey, ObservableList<TValue>>,
|
|
28
|
+
_maid: Maid.Maid,
|
|
29
|
+
|
|
30
|
+
--[=[
|
|
31
|
+
Fires when an item is added
|
|
32
|
+
@readonly
|
|
33
|
+
@prop ListAdded Signal<TKey>
|
|
34
|
+
@within ObservableMapSet
|
|
35
|
+
]=]
|
|
36
|
+
ListAdded: _Signal.Signal<TKey, ObservableList<TValue>>,
|
|
37
|
+
|
|
38
|
+
--[=[
|
|
39
|
+
Fires when an item is removed
|
|
40
|
+
@readonly
|
|
41
|
+
@prop ListRemoved Signal<TKey>
|
|
42
|
+
@within ObservableMapSet
|
|
43
|
+
]=]
|
|
44
|
+
ListRemoved: _Signal.Signal<TKey>,
|
|
45
|
+
|
|
46
|
+
--[=[
|
|
47
|
+
Fires when the count changes.
|
|
48
|
+
@prop CountChanged RBXScriptSignal
|
|
49
|
+
@within ObservableMap
|
|
50
|
+
]=]
|
|
51
|
+
CountChanged: _Signal.Signal<number>,
|
|
52
|
+
},
|
|
53
|
+
{} :: typeof({ __index = ObservableMapList })
|
|
54
|
+
))
|
|
55
|
+
|
|
20
56
|
--[=[
|
|
21
57
|
Constructs a new ObservableMapList
|
|
22
58
|
@return ObservableMapList<TKey, TValue>
|
|
23
59
|
]=]
|
|
24
|
-
function ObservableMapList.new()
|
|
25
|
-
local self = setmetatable({}, ObservableMapList)
|
|
60
|
+
function ObservableMapList.new<TKey, TValue>(): ObservableMapList<TKey, TValue>
|
|
61
|
+
local self: ObservableMapList<TKey, TValue> = setmetatable({} :: any, ObservableMapList)
|
|
26
62
|
|
|
27
63
|
self._maid = Maid.new()
|
|
28
64
|
self._observableMapOfLists = self._maid:Add(ObservableMap.new())
|
|
29
65
|
|
|
30
|
-
--[=[
|
|
31
|
-
Fires when an item is added
|
|
32
|
-
@readonly
|
|
33
|
-
@prop ListAdded Signal<TKey>
|
|
34
|
-
@within ObservableMapSet
|
|
35
|
-
]=]
|
|
36
66
|
self.ListAdded = assert(self._observableMapOfLists.KeyAdded, "Bad KeyAdded") -- :Fire(key, set)
|
|
37
|
-
|
|
38
|
-
--[=[
|
|
39
|
-
Fires when an item is removed
|
|
40
|
-
@readonly
|
|
41
|
-
@prop ListRemoved Signal<TKey>
|
|
42
|
-
@within ObservableMapSet
|
|
43
|
-
]=]
|
|
44
67
|
self.ListRemoved = assert(self._observableMapOfLists.KeyRemoved, "Bad KeyRemoved") -- :Fire(key)
|
|
45
|
-
|
|
46
|
-
--[=[
|
|
47
|
-
Fires when the count changes.
|
|
48
|
-
@prop CountChanged RBXScriptSignal
|
|
49
|
-
@within ObservableMap
|
|
50
|
-
]=]
|
|
51
68
|
self.CountChanged = assert(self._observableMapOfLists.CountChanged, "Bad CountChanged")
|
|
52
69
|
|
|
53
70
|
return self
|
|
@@ -65,7 +82,7 @@ end
|
|
|
65
82
|
@param observeKey Observable<TKey>
|
|
66
83
|
@return MaidTask -- Cleanup object that will remove the entry
|
|
67
84
|
]=]
|
|
68
|
-
function ObservableMapList
|
|
85
|
+
function ObservableMapList.Push<TKey, TValue>(self: ObservableMapList<TKey, TValue>, observeKey, entry: TValue): Maid.Maid
|
|
69
86
|
assert(observeKey ~= nil, "Bad observeKey")
|
|
70
87
|
assert(entry ~= nil, "Bad entry")
|
|
71
88
|
|
|
@@ -98,7 +115,7 @@ end
|
|
|
98
115
|
@param key TKey
|
|
99
116
|
@return TValue | nil
|
|
100
117
|
]=]
|
|
101
|
-
function ObservableMapList
|
|
118
|
+
function ObservableMapList.GetFirstItemForKey<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey): TValue?
|
|
102
119
|
assert(key ~= nil, "Bad key")
|
|
103
120
|
|
|
104
121
|
local observableList = self:GetListForKey(key)
|
|
@@ -123,9 +140,13 @@ end
|
|
|
123
140
|
|
|
124
141
|
@param key TKey
|
|
125
142
|
@param index number
|
|
126
|
-
@return TValue
|
|
143
|
+
@return TValue?
|
|
127
144
|
]=]
|
|
128
|
-
function ObservableMapList
|
|
145
|
+
function ObservableMapList.GetItemForKeyAtIndex<TKey, TValue>(
|
|
146
|
+
self: ObservableMapList<TKey, TValue>,
|
|
147
|
+
key: TKey,
|
|
148
|
+
index: number
|
|
149
|
+
): TValue?
|
|
129
150
|
assert(key ~= nil, "Bad key")
|
|
130
151
|
assert(type(index) == "number", "Bad index")
|
|
131
152
|
|
|
@@ -142,7 +163,7 @@ end
|
|
|
142
163
|
|
|
143
164
|
@return number
|
|
144
165
|
]=]
|
|
145
|
-
function ObservableMapList
|
|
166
|
+
function ObservableMapList.GetListCount<TKey, TValue>(self: ObservableMapList<TKey, TValue>): number
|
|
146
167
|
return self._observableMapOfLists:GetCount()
|
|
147
168
|
end
|
|
148
169
|
|
|
@@ -153,7 +174,7 @@ ObservableMapList.__len = ObservableMapList.GetListCount
|
|
|
153
174
|
|
|
154
175
|
@return Observable<number>
|
|
155
176
|
]=]
|
|
156
|
-
function ObservableMapList
|
|
177
|
+
function ObservableMapList.ObserveListCount<TKey, TValue>(self: ObservableMapList<TKey, TValue>): Observable.Observable<number>
|
|
157
178
|
return self._observableMapOfLists:ObserveCount()
|
|
158
179
|
end
|
|
159
180
|
|
|
@@ -162,9 +183,9 @@ end
|
|
|
162
183
|
|
|
163
184
|
@param key TKey
|
|
164
185
|
@param index number
|
|
165
|
-
@return
|
|
186
|
+
@return TValue?
|
|
166
187
|
]=]
|
|
167
|
-
function ObservableMapList
|
|
188
|
+
function ObservableMapList.GetAtListIndex<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey, index: number): TValue?
|
|
168
189
|
assert(key ~= nil, "Bad key")
|
|
169
190
|
assert(type(index) == "number", "Bad index")
|
|
170
191
|
|
|
@@ -183,19 +204,23 @@ end
|
|
|
183
204
|
@param index number
|
|
184
205
|
@return Observable<TValue?>
|
|
185
206
|
]=]
|
|
186
|
-
function ObservableMapList
|
|
207
|
+
function ObservableMapList.ObserveAtListIndex<TKey, TValue>(
|
|
208
|
+
self: ObservableMapList<TKey, TValue>,
|
|
209
|
+
key: TKey,
|
|
210
|
+
index: number
|
|
211
|
+
): Observable.Observable<TValue?>
|
|
187
212
|
assert(key ~= nil, "Bad key")
|
|
188
213
|
assert(type(index) == "number", "Bad index")
|
|
189
214
|
|
|
190
215
|
return self._observableMapOfLists:ObserveAtKey(key):Pipe({
|
|
191
|
-
Rx.switchMap(function(list)
|
|
216
|
+
Rx.switchMap(function(list): any
|
|
192
217
|
if list then
|
|
193
218
|
return list:ObserveAtIndex(index)
|
|
194
219
|
else
|
|
195
220
|
return Rx.of(nil)
|
|
196
221
|
end
|
|
197
|
-
end)
|
|
198
|
-
})
|
|
222
|
+
end) :: any,
|
|
223
|
+
}) :: any
|
|
199
224
|
end
|
|
200
225
|
|
|
201
226
|
--[=[
|
|
@@ -203,7 +228,7 @@ end
|
|
|
203
228
|
|
|
204
229
|
@return { TKey }
|
|
205
230
|
]=]
|
|
206
|
-
function ObservableMapList
|
|
231
|
+
function ObservableMapList.GetKeyList<TKey, TValue>(self: ObservableMapList<TKey, TValue>): { TKey }
|
|
207
232
|
return self._observableMapOfLists:GetKeyList()
|
|
208
233
|
end
|
|
209
234
|
|
|
@@ -211,7 +236,7 @@ end
|
|
|
211
236
|
Observes the list of all keys.
|
|
212
237
|
@return Observable<{ TKey }>
|
|
213
238
|
]=]
|
|
214
|
-
function ObservableMapList
|
|
239
|
+
function ObservableMapList.ObserveKeyList<TKey, TValue>(self: ObservableMapList<TKey, TValue>): Observable.Observable<{ TKey }>
|
|
215
240
|
return self._observableMapOfLists:ObserveKeyList()
|
|
216
241
|
end
|
|
217
242
|
|
|
@@ -219,7 +244,9 @@ end
|
|
|
219
244
|
Observes all keys in the map
|
|
220
245
|
@return Observable<Brio<TKey>>
|
|
221
246
|
]=]
|
|
222
|
-
function ObservableMapList
|
|
247
|
+
function ObservableMapList.ObserveKeysBrio<TKey, TValue>(
|
|
248
|
+
self: ObservableMapList<TKey, TValue>
|
|
249
|
+
): Observable.Observable<_Brio.Brio<TKey>>
|
|
223
250
|
return self._observableMapOfLists:ObserveKeysBrio()
|
|
224
251
|
end
|
|
225
252
|
|
|
@@ -230,19 +257,23 @@ end
|
|
|
230
257
|
@param index number
|
|
231
258
|
@return Observable<Brio<TValue>>
|
|
232
259
|
]=]
|
|
233
|
-
function ObservableMapList
|
|
260
|
+
function ObservableMapList.ObserveAtListIndexBrio<TKey, TValue>(
|
|
261
|
+
self: ObservableMapList<TKey, TValue>,
|
|
262
|
+
key: TKey,
|
|
263
|
+
index: number
|
|
264
|
+
): Observable.Observable<_Brio.Brio<TValue>>
|
|
234
265
|
assert(key ~= nil, "Bad key")
|
|
235
266
|
assert(type(index) == "number", "Bad index")
|
|
236
267
|
|
|
237
268
|
return self._observableMapOfLists:ObserveAtKeyBrio(key):Pipe({
|
|
238
269
|
RxBrioUtils.switchMapBrio(function(list)
|
|
239
270
|
return list:ObserveAtIndexBrio(index)
|
|
240
|
-
end)
|
|
241
|
-
RxBrioUtils.toBrio()
|
|
271
|
+
end) :: any,
|
|
272
|
+
RxBrioUtils.toBrio() :: any,
|
|
242
273
|
RxBrioUtils.where(function(value)
|
|
243
274
|
return value ~= nil
|
|
244
|
-
end)
|
|
245
|
-
})
|
|
275
|
+
end) :: any,
|
|
276
|
+
}) :: any
|
|
246
277
|
end
|
|
247
278
|
|
|
248
279
|
--[=[
|
|
@@ -251,18 +282,21 @@ end
|
|
|
251
282
|
@param key TKey
|
|
252
283
|
@return Observable<Brio<TValue>>
|
|
253
284
|
]=]
|
|
254
|
-
function ObservableMapList
|
|
285
|
+
function ObservableMapList.ObserveItemsForKeyBrio<TKey, TValue>(
|
|
286
|
+
self: ObservableMapList<TKey, TValue>,
|
|
287
|
+
key: TKey
|
|
288
|
+
): Observable.Observable<_Brio.Brio<TValue>>
|
|
255
289
|
assert(key ~= nil, "Bad key")
|
|
256
290
|
|
|
257
291
|
return self._observableMapOfLists:ObserveAtKeyBrio(key):Pipe({
|
|
258
|
-
RxBrioUtils.switchMapBrio(function(list)
|
|
292
|
+
RxBrioUtils.switchMapBrio(function(list): any
|
|
259
293
|
if list then
|
|
260
294
|
return list:ObserveItemsBrio()
|
|
261
295
|
else
|
|
262
296
|
return Rx.EMPTY
|
|
263
297
|
end
|
|
264
|
-
end)
|
|
265
|
-
})
|
|
298
|
+
end) :: any,
|
|
299
|
+
}) :: any
|
|
266
300
|
end
|
|
267
301
|
|
|
268
302
|
--[=[
|
|
@@ -271,7 +305,7 @@ end
|
|
|
271
305
|
@param key TKey
|
|
272
306
|
@return { TValue }
|
|
273
307
|
]=]
|
|
274
|
-
function ObservableMapList
|
|
308
|
+
function ObservableMapList.GetListFromKey<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey): { TValue }
|
|
275
309
|
assert(key ~= nil, "Bad key")
|
|
276
310
|
|
|
277
311
|
local observableList = self:GetListForKey(key)
|
|
@@ -287,7 +321,7 @@ end
|
|
|
287
321
|
@param key TKey
|
|
288
322
|
@return ObservableList<TValue>
|
|
289
323
|
]=]
|
|
290
|
-
function ObservableMapList
|
|
324
|
+
function ObservableMapList.GetListForKey<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey): any
|
|
291
325
|
assert(key ~= nil, "Bad key")
|
|
292
326
|
|
|
293
327
|
return self._observableMapOfLists:Get(key)
|
|
@@ -297,9 +331,9 @@ end
|
|
|
297
331
|
Gets a list of all of the entries at the given index, if it exists
|
|
298
332
|
|
|
299
333
|
@param index number
|
|
300
|
-
@return
|
|
334
|
+
@return { TValue}
|
|
301
335
|
]=]
|
|
302
|
-
function ObservableMapList
|
|
336
|
+
function ObservableMapList.GetListOfValuesAtListIndex<TKey, TValue>(self: ObservableMapList<TKey, TValue>, index: number): { TValue }
|
|
303
337
|
assert(type(index) == "number", "Bad index")
|
|
304
338
|
|
|
305
339
|
local list = table.create(self._observableMapOfLists:GetCount())
|
|
@@ -320,7 +354,10 @@ end
|
|
|
320
354
|
@param key TKey
|
|
321
355
|
@return Observable<ObservableList<TValue>>
|
|
322
356
|
]=]
|
|
323
|
-
function ObservableMapList
|
|
357
|
+
function ObservableMapList.ObserveList<TKey, TValue>(
|
|
358
|
+
self: ObservableMapList<TKey, TValue>,
|
|
359
|
+
key: TKey
|
|
360
|
+
): Observable.Observable<ObservableList<TValue>>
|
|
324
361
|
assert(key ~= nil, "Bad key")
|
|
325
362
|
|
|
326
363
|
return self._observableMapOfLists:ObserveAtKey(key)
|
|
@@ -332,7 +369,10 @@ end
|
|
|
332
369
|
@param key TKey
|
|
333
370
|
@return Observable<Brio<ObservableList<TValue>>>
|
|
334
371
|
]=]
|
|
335
|
-
function ObservableMapList
|
|
372
|
+
function ObservableMapList.ObserveListBrio<TKey, TValue>(
|
|
373
|
+
self: ObservableMapList<TKey, TValue>,
|
|
374
|
+
key: TKey
|
|
375
|
+
): Observable.Observable<_Brio.Brio<ObservableList<TValue>>>
|
|
336
376
|
assert(key ~= nil, "Bad key")
|
|
337
377
|
|
|
338
378
|
return self._observableMapOfLists:ObserveAtKeyBrio(key)
|
|
@@ -343,7 +383,9 @@ end
|
|
|
343
383
|
|
|
344
384
|
@return Observable<Brio<ObservableList<TValue>>>
|
|
345
385
|
]=]
|
|
346
|
-
function ObservableMapList
|
|
386
|
+
function ObservableMapList.ObserveListsBrio<TKey, TValue>(
|
|
387
|
+
self: ObservableMapList<TKey, TValue>
|
|
388
|
+
): Observable.Observable<_Brio.Brio<ObservableList<TValue>>>
|
|
347
389
|
return self._observableMapOfLists:ObserveValuesBrio()
|
|
348
390
|
end
|
|
349
391
|
|
|
@@ -353,30 +395,33 @@ end
|
|
|
353
395
|
@param key TKey
|
|
354
396
|
@return Observable<number>
|
|
355
397
|
]=]
|
|
356
|
-
function ObservableMapList
|
|
398
|
+
function ObservableMapList.ObserveCountForKey<TKey, TValue>(
|
|
399
|
+
self: ObservableMapList<TKey, TValue>,
|
|
400
|
+
key: TKey
|
|
401
|
+
): Observable.Observable<number>
|
|
357
402
|
assert(key ~= nil, "Bad key")
|
|
358
403
|
|
|
359
404
|
return self:ObserveListBrio(key):Pipe({
|
|
360
405
|
RxBrioUtils.switchMapBrio(function(observableList)
|
|
361
406
|
return observableList:ObserveCount()
|
|
362
|
-
end)
|
|
363
|
-
RxBrioUtils.emitOnDeath(0)
|
|
364
|
-
})
|
|
407
|
+
end) :: any,
|
|
408
|
+
RxBrioUtils.emitOnDeath(0) :: any,
|
|
409
|
+
}) :: any
|
|
365
410
|
end
|
|
366
411
|
|
|
367
|
-
function ObservableMapList
|
|
412
|
+
function ObservableMapList._addToList<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey, entry: TValue): () -> ()
|
|
368
413
|
local list = self:_getOrCreateList(key)
|
|
369
414
|
return list:Add(entry)
|
|
370
415
|
end
|
|
371
416
|
|
|
372
|
-
function ObservableMapList
|
|
417
|
+
function ObservableMapList._getOrCreateList<TKey, TValue>(self: ObservableMapList<TKey, TValue>, key: TKey): ObservableList<TValue>
|
|
373
418
|
local existing = self._observableMapOfLists:Get(key)
|
|
374
419
|
if existing then
|
|
375
420
|
return existing
|
|
376
421
|
end
|
|
377
422
|
|
|
378
423
|
local maid = Maid.new()
|
|
379
|
-
local list = maid:Add(ObservableList.new(
|
|
424
|
+
local list = maid:Add(ObservableList.new())
|
|
380
425
|
|
|
381
426
|
maid:GiveTask(list.CountChanged:Connect(function(count)
|
|
382
427
|
if count <= 0 then
|
|
@@ -393,9 +438,9 @@ end
|
|
|
393
438
|
--[=[
|
|
394
439
|
Cleans up the ObservableMapList and sets the metatable to nil.
|
|
395
440
|
]=]
|
|
396
|
-
function ObservableMapList
|
|
441
|
+
function ObservableMapList.Destroy<TKey, TValue>(self: ObservableMapList<TKey, TValue>)
|
|
397
442
|
self._maid:DoCleaning()
|
|
398
|
-
setmetatable(self, nil)
|
|
443
|
+
setmetatable(self :: any, nil)
|
|
399
444
|
end
|
|
400
445
|
|
|
401
446
|
|
|
@@ -30,7 +30,7 @@ export type ObservableMapSet<TKey, TValue> = typeof(setmetatable(
|
|
|
30
30
|
SetRemoved: _Signal.Signal<TKey>,
|
|
31
31
|
CountChanged: _Signal.Signal<number>,
|
|
32
32
|
},
|
|
33
|
-
ObservableMapSet
|
|
33
|
+
{} :: typeof({ __index = ObservableMapSet })
|
|
34
34
|
))
|
|
35
35
|
|
|
36
36
|
--[=[
|
|
@@ -105,9 +105,9 @@ function ObservableMapSet.Push<TKey, TValue>(
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
-- Ensure self-cleanup when map cleans up
|
|
108
|
-
self._maid[maid
|
|
108
|
+
self._maid[maid] = maid
|
|
109
109
|
maid:GiveTask(function()
|
|
110
|
-
self._maid[maid
|
|
110
|
+
self._maid[maid] = nil
|
|
111
111
|
end)
|
|
112
112
|
|
|
113
113
|
return maid
|
|
@@ -287,9 +287,9 @@ function ObservableMapSet.ObserveCountForKey<TKey, TValue>(
|
|
|
287
287
|
return self:ObserveSetBrio(key):Pipe({
|
|
288
288
|
RxBrioUtils.switchMapBrio(function(observableSet)
|
|
289
289
|
return observableSet:ObserveCount()
|
|
290
|
-
end),
|
|
291
|
-
RxBrioUtils.emitOnDeath(0),
|
|
292
|
-
}) :: any
|
|
290
|
+
end) :: any,
|
|
291
|
+
RxBrioUtils.emitOnDeath(0) :: any,
|
|
292
|
+
} :: any) :: any
|
|
293
293
|
end
|
|
294
294
|
|
|
295
295
|
function ObservableMapSet._addToSet<TKey, TValue>(self: ObservableMapSet<TKey, TValue>, key: TKey, entry: TValue): () -> ()
|
|
@@ -311,12 +311,12 @@ function ObservableMapSet._getOrCreateSet<TKey, TValue>(
|
|
|
311
311
|
|
|
312
312
|
maid:GiveTask(set.CountChanged:Connect(function(count)
|
|
313
313
|
if count <= 0 then
|
|
314
|
-
self._maid[set
|
|
314
|
+
self._maid[set] = nil
|
|
315
315
|
end
|
|
316
316
|
end))
|
|
317
317
|
|
|
318
318
|
maid:GiveTask(self._observableMapOfSets:Set(key, set))
|
|
319
|
-
self._maid[set
|
|
319
|
+
self._maid[set] = maid
|
|
320
320
|
|
|
321
321
|
return set
|
|
322
322
|
end
|
|
@@ -29,7 +29,7 @@ export type ObservableSet<T> = typeof(setmetatable(
|
|
|
29
29
|
ItemRemoved: Signal.Signal<T>,
|
|
30
30
|
CountChanged: Signal.Signal<number>,
|
|
31
31
|
},
|
|
32
|
-
ObservableSet
|
|
32
|
+
{} :: typeof({ __index = ObservableSet })
|
|
33
33
|
))
|
|
34
34
|
|
|
35
35
|
--[=[
|
|
@@ -127,12 +127,12 @@ function ObservableSet.ObserveItemsBrio<T>(self: ObservableSet<T>): Observable.O
|
|
|
127
127
|
handleItem(item)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
self._maid[sub
|
|
130
|
+
self._maid[sub] = maid
|
|
131
131
|
maid:GiveTask(function()
|
|
132
132
|
for _, brio: any in brios do
|
|
133
133
|
brio:Destroy()
|
|
134
134
|
end
|
|
135
|
-
self._maid[sub
|
|
135
|
+
self._maid[sub] = nil
|
|
136
136
|
sub:Complete()
|
|
137
137
|
end)
|
|
138
138
|
|
|
@@ -167,9 +167,9 @@ function ObservableSet.ObserveContains<T>(self: ObservableSet<T>, item: T): Obse
|
|
|
167
167
|
sub:Fire(doesContain)
|
|
168
168
|
end))
|
|
169
169
|
|
|
170
|
-
self._maid[sub
|
|
170
|
+
self._maid[sub] = maid
|
|
171
171
|
maid:GiveTask(function()
|
|
172
|
-
self._maid[sub
|
|
172
|
+
self._maid[sub] = nil
|
|
173
173
|
sub:Complete()
|
|
174
174
|
end)
|
|
175
175
|
|
|
@@ -55,7 +55,7 @@ export type ObservableSortedList<T> = typeof(setmetatable(
|
|
|
55
55
|
OrderChanged: Signal.Signal<()>,
|
|
56
56
|
CountChanged: Signal.Signal<number>,
|
|
57
57
|
},
|
|
58
|
-
ObservableSortedList
|
|
58
|
+
{} :: typeof({ __index = ObservableSortedList })
|
|
59
59
|
))
|
|
60
60
|
|
|
61
61
|
--[=[
|
|
@@ -190,7 +190,7 @@ end
|
|
|
190
190
|
function ObservableSortedList._iterateNodesRange<T>(
|
|
191
191
|
self: ObservableSortedList<T>,
|
|
192
192
|
start: number,
|
|
193
|
-
finish: number
|
|
193
|
+
finish: number?
|
|
194
194
|
): SortFunctionUtils.WrappedIterator<number, SortedNode.SortedNode<T>>
|
|
195
195
|
if self._root then
|
|
196
196
|
return self._root:IterateNodesRange(start, finish)
|
|
@@ -366,7 +366,7 @@ end
|
|
|
366
366
|
function ObservableSortedList.ObserveIndexByKey<T>(
|
|
367
367
|
self: ObservableSortedList<T>,
|
|
368
368
|
node: SortedNode.SortedNode<T>
|
|
369
|
-
): Observable.Observable<number
|
|
369
|
+
): Observable.Observable<number>
|
|
370
370
|
assert(SortedNode.isSortedNode(node), "Bad node")
|
|
371
371
|
|
|
372
372
|
return self._nodeIndexObservables:Observe(node, function(sub)
|
|
@@ -443,7 +443,7 @@ function ObservableSortedList.Add<T>(
|
|
|
443
443
|
self:_assignSortValue(node, sortValue)
|
|
444
444
|
end))
|
|
445
445
|
elseif observeValue ~= nil then
|
|
446
|
-
self:_assignSortValue(node, observeValue)
|
|
446
|
+
self:_assignSortValue(node, observeValue :: number)
|
|
447
447
|
else
|
|
448
448
|
error("Bad observeValue")
|
|
449
449
|
end
|
|
@@ -661,7 +661,7 @@ end
|
|
|
661
661
|
function ObservableSortedList.RemoveByKey<T>(self: ObservableSortedList<T>, node: SortedNode.SortedNode<T>)
|
|
662
662
|
assert(SortedNode.isSortedNode(node), "Bad node")
|
|
663
663
|
|
|
664
|
-
self._maid[node
|
|
664
|
+
self._maid[node] = nil
|
|
665
665
|
end
|
|
666
666
|
|
|
667
667
|
--[=[
|
|
@@ -41,7 +41,7 @@ export type SortedNode<T> = typeof(setmetatable(
|
|
|
41
41
|
descendantCount: number,
|
|
42
42
|
data: T,
|
|
43
43
|
},
|
|
44
|
-
SortedNode
|
|
44
|
+
{} :: typeof({ __index = SortedNode })
|
|
45
45
|
))
|
|
46
46
|
|
|
47
47
|
function SortedNode.new<T>(data: T): SortedNode<T>
|
|
@@ -113,7 +113,7 @@ end
|
|
|
113
113
|
function SortedNode.IterateNodesRange<T>(
|
|
114
114
|
self: SortedNode<T>,
|
|
115
115
|
start: number,
|
|
116
|
-
finish: number
|
|
116
|
+
finish: number?
|
|
117
117
|
): _SortFunctionUtils.WrappedIterator<number, SortedNode<T>>
|
|
118
118
|
assert(type(start) == "number", "Bad start")
|
|
119
119
|
assert(type(finish) == "number" or finish == nil, "Bad finish")
|
|
@@ -20,7 +20,7 @@ export type SortedNodeValue<T> = typeof(setmetatable(
|
|
|
20
20
|
_value: T,
|
|
21
21
|
_compare: CompareFunction<T>,
|
|
22
22
|
},
|
|
23
|
-
SortedNodeValue
|
|
23
|
+
{} :: typeof({ __index = SortedNodeValue })
|
|
24
24
|
))
|
|
25
25
|
|
|
26
26
|
function SortedNodeValue.new<T>(value: T, compare: CompareFunction<T>): SortedNodeValue<T>
|