@quenty/observablecollection 3.1.0 → 3.1.1-canary.270.0fe7bd3.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 +11 -0
- package/package.json +10 -10
- package/src/Shared/ObservableMapSet.lua +39 -0
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
|
+
## [3.1.1-canary.270.0fe7bd3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@3.1.0...@quenty/observablecollection@3.1.1-canary.270.0fe7bd3.0) (2022-07-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add ObservableMapSet:GetSetCount() and ObservableMapSet:ObserveSetCount() ([6a25f61](https://github.com/Quenty/NevermoreEngine/commit/6a25f61d8dcadd9dda56daf1a52c4b4186740efe))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@3.0.0...@quenty/observablecollection@3.1.0) (2022-06-21)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/observablecollection",
|
|
3
|
-
"version": "3.1.0",
|
|
3
|
+
"version": "3.1.1-canary.270.0fe7bd3.0",
|
|
4
4
|
"description": "An observable set",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"Quenty"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/brio": "
|
|
31
|
-
"@quenty/loader": "
|
|
32
|
-
"@quenty/maid": "
|
|
33
|
-
"@quenty/promise": "
|
|
34
|
-
"@quenty/rx": "
|
|
35
|
-
"@quenty/signal": "
|
|
36
|
-
"@quenty/symbol": "
|
|
37
|
-
"@quenty/valuebaseutils": "
|
|
30
|
+
"@quenty/brio": "6.1.0",
|
|
31
|
+
"@quenty/loader": "5.0.0",
|
|
32
|
+
"@quenty/maid": "2.3.0",
|
|
33
|
+
"@quenty/promise": "5.0.0",
|
|
34
|
+
"@quenty/rx": "5.1.0",
|
|
35
|
+
"@quenty/signal": "2.2.0",
|
|
36
|
+
"@quenty/symbol": "2.1.0",
|
|
37
|
+
"@quenty/valuebaseutils": "5.1.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0fe7bd3216177265038ff7d3f83d1d47e748141c"
|
|
43
43
|
}
|
|
@@ -13,6 +13,7 @@ local ObservableSet = require("ObservableSet")
|
|
|
13
13
|
local Signal = require("Signal")
|
|
14
14
|
local Brio = require("Brio")
|
|
15
15
|
local RxBrioUtils = require("RxBrioUtils")
|
|
16
|
+
local RxValueBaseUtils = require("RxValueBaseUtils")
|
|
16
17
|
|
|
17
18
|
local ObservableMapSet = {}
|
|
18
19
|
ObservableMapSet.ClassName = "ObservableMapSet"
|
|
@@ -46,6 +47,10 @@ function ObservableMapSet.new()
|
|
|
46
47
|
self.SetRemoved = Signal.new() -- :Fire(key)
|
|
47
48
|
self._maid:GiveTask(self.SetRemoved)
|
|
48
49
|
|
|
50
|
+
self._setCount = Instance.new("IntValue")
|
|
51
|
+
self._setCount.Value = 0
|
|
52
|
+
self._maid:GiveTask(self._setCount)
|
|
53
|
+
|
|
49
54
|
return self
|
|
50
55
|
end
|
|
51
56
|
|
|
@@ -89,6 +94,27 @@ function ObservableMapSet:Add(entry, observeKey)
|
|
|
89
94
|
return maid
|
|
90
95
|
end
|
|
91
96
|
|
|
97
|
+
--[=[
|
|
98
|
+
Gets how many sets exist
|
|
99
|
+
@return number
|
|
100
|
+
]=]
|
|
101
|
+
function ObservableMapSet:GetSetCount()
|
|
102
|
+
return self._setCount.Value
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
--[=[
|
|
106
|
+
Observes how many sets exist
|
|
107
|
+
@return Observable<number>
|
|
108
|
+
]=]
|
|
109
|
+
function ObservableMapSet:ObserveSetCount()
|
|
110
|
+
return RxValueBaseUtils.observeValue(self._setCount)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
--[=[
|
|
114
|
+
Observes all items for the given key
|
|
115
|
+
@param key TKey
|
|
116
|
+
@return Observable<Brio<TValue>>
|
|
117
|
+
]=]
|
|
92
118
|
function ObservableMapSet:ObserveItemsForKeyBrio(key)
|
|
93
119
|
assert(key ~= nil, "Bad key")
|
|
94
120
|
|
|
@@ -126,6 +152,11 @@ function ObservableMapSet:ObserveItemsForKeyBrio(key)
|
|
|
126
152
|
end)
|
|
127
153
|
end
|
|
128
154
|
|
|
155
|
+
--[=[
|
|
156
|
+
Gets a list for a given key
|
|
157
|
+
@param key TKey
|
|
158
|
+
@return { TValue }
|
|
159
|
+
]=]
|
|
129
160
|
function ObservableMapSet:GetListForKey(key)
|
|
130
161
|
assert(key ~= nil, "Bad key")
|
|
131
162
|
|
|
@@ -137,6 +168,11 @@ function ObservableMapSet:GetListForKey(key)
|
|
|
137
168
|
return observableSet:GetList()
|
|
138
169
|
end
|
|
139
170
|
|
|
171
|
+
--[=[
|
|
172
|
+
Gets the observable set for the given key
|
|
173
|
+
@param key TKey
|
|
174
|
+
@return ObservableSet<TValue>
|
|
175
|
+
]=]
|
|
140
176
|
function ObservableMapSet:GetObservableSetForKey(key)
|
|
141
177
|
assert(key ~= nil, "Bad key")
|
|
142
178
|
|
|
@@ -225,6 +261,8 @@ function ObservableMapSet:_removeObservableSet(key)
|
|
|
225
261
|
if self.SetRemoved.Destroy then
|
|
226
262
|
self.SetRemoved:Fire(key)
|
|
227
263
|
end
|
|
264
|
+
|
|
265
|
+
self._setCount.Value = self._setCount.Value - 1
|
|
228
266
|
end
|
|
229
267
|
end
|
|
230
268
|
|
|
@@ -240,6 +278,7 @@ function ObservableMapSet:_getOrCreateObservableSet(key)
|
|
|
240
278
|
self._observableSetMap[key] = set
|
|
241
279
|
|
|
242
280
|
self.SetAdded:Fire(key, set)
|
|
281
|
+
self._setCount.Value = self._setCount.Value + 1
|
|
243
282
|
|
|
244
283
|
self._maid[set] = maid
|
|
245
284
|
return set
|