@quenty/observablecollection 12.20.0 → 12.20.1

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.
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Holds a map of sets. That is, for a given key, a set of all valid entries. This is great
3
4
  for looking up something that may have duplicate keys, like configurations or other things.
@@ -13,22 +14,36 @@ local ObservableMap = require("ObservableMap")
13
14
  local ObservableSet = require("ObservableSet")
14
15
  local Rx = require("Rx")
15
16
  local RxBrioUtils = require("RxBrioUtils")
17
+ local _Brio = require("Brio")
18
+ local _Signal = require("Signal")
19
+ local _Table = require("Table")
16
20
 
17
21
  local ObservableMapSet = {}
18
22
  ObservableMapSet.ClassName = "ObservableMapSet"
19
23
  ObservableMapSet.__index = ObservableMapSet
20
24
 
25
+ export type ObservableMapSet<TKey, TValue> = typeof(setmetatable(
26
+ {} :: {
27
+ _observableMapOfSets: any, -- ObservableMap.ObservableMap<TKey, ObservableSet.ObservableSet<TValue>>,
28
+ _maid: Maid.Maid,
29
+ SetAdded: _Signal.Signal<TKey>,
30
+ SetRemoved: _Signal.Signal<TKey>,
31
+ CountChanged: _Signal.Signal<number>,
32
+ },
33
+ ObservableMapSet
34
+ ))
35
+
21
36
  --[=[
22
37
  Constructs a new ObservableMapSet
23
38
  @return ObservableMapSet<TKey, TValue>
24
39
  ]=]
25
- function ObservableMapSet.new()
26
- local self = setmetatable({}, ObservableMapSet)
40
+ function ObservableMapSet.new<TKey, TValue>(): ObservableMapSet<TKey, TValue>
41
+ local self = setmetatable({} :: any, ObservableMapSet)
27
42
 
28
43
  self._maid = Maid.new()
29
44
  self._observableMapOfSets = self._maid:Add(ObservableMap.new())
30
45
 
31
- --[=[
46
+ --[=[
32
47
  Fires when an item is added
33
48
  @readonly
34
49
  @prop SetAdded Signal<TKey>
@@ -36,7 +51,7 @@ function ObservableMapSet.new()
36
51
  ]=]
37
52
  self.SetAdded = assert(self._observableMapOfSets.KeyAdded, "Bad KeyAdded") -- :Fire(key, set)
38
53
 
39
- --[=[
54
+ --[=[
40
55
  Fires when an item is removed
41
56
  @readonly
42
57
  @prop SetRemoved Signal<TKey>
@@ -44,7 +59,7 @@ function ObservableMapSet.new()
44
59
  ]=]
45
60
  self.SetRemoved = assert(self._observableMapOfSets.KeyRemoved, "Bad KeyRemoved") -- :Fire(key)
46
61
 
47
- --[=[
62
+ --[=[
48
63
  Fires when the count changes.
49
64
  @prop CountChanged RBXScriptSignal
50
65
  @within ObservableMap
@@ -67,14 +82,18 @@ end
67
82
  @return MaidTask -- Cleanup object that will remove the entry
68
83
  ]=]
69
84
 
70
- function ObservableMapSet:Push(observeKey, entry)
85
+ function ObservableMapSet.Push<TKey, TValue>(
86
+ self: ObservableMapSet<TKey, TValue>,
87
+ observeKey: Observable.Observable<TKey> | TKey,
88
+ entry: TValue
89
+ ): Maid.Maid
71
90
  assert(observeKey ~= nil, "Bad observeKey")
72
91
  assert(entry ~= nil, "Bad entry")
73
92
 
74
93
  local maid = Maid.new()
75
94
 
76
95
  if Observable.isObservable(observeKey) then
77
- maid:GiveTask(observeKey:Subscribe(function(key)
96
+ maid:GiveTask((observeKey :: any):Subscribe(function(key)
78
97
  maid._currentAddValue = nil
79
98
 
80
99
  if key ~= nil then
@@ -82,13 +101,13 @@ function ObservableMapSet:Push(observeKey, entry)
82
101
  end
83
102
  end))
84
103
  else
85
- maid:GiveTask(self:_addToSet(observeKey, entry))
104
+ maid:GiveTask(self:_addToSet(observeKey :: any, entry))
86
105
  end
87
106
 
88
107
  -- Ensure self-cleanup when map cleans up
89
- self._maid[maid] = maid
108
+ self._maid[maid :: any] = maid
90
109
  maid:GiveTask(function()
91
- self._maid[maid] = nil
110
+ self._maid[maid :: any] = nil
92
111
  end)
93
112
 
94
113
  return maid
@@ -108,12 +127,20 @@ end
108
127
  @param observeKey Observable<TKey> | TKey
109
128
  @return MaidTask -- Cleanup object that will remove the entry
110
129
  ]=]
111
- function ObservableMapSet:Add(entry, observeKey)
130
+ function ObservableMapSet.Add<TKey, TValue>(
131
+ self: ObservableMapSet<TKey, TValue>,
132
+ entry: TValue,
133
+ observeKey: Observable.Observable<TKey> | TKey
134
+ ): Maid.Maid
112
135
  assert(Observable.isObservable(observeKey), "Bad observeKey")
113
136
  assert(entry ~= nil, "Bad entry")
114
137
 
115
- warn(string.format("[ObservableMapSet.Add] - This API call will swap observable key order eventually. Use ObservableMapSet.Push for now to suppress this warning.\n%s",
116
- debug.traceback()))
138
+ warn(
139
+ string.format(
140
+ "[ObservableMapSet.Add] - This API call will swap observable key order eventually. Use ObservableMapSet.Push for now to suppress this warning.\n%s",
141
+ debug.traceback()
142
+ )
143
+ )
117
144
 
118
145
  return self:Push(observeKey, entry)
119
146
  end
@@ -122,7 +149,7 @@ end
122
149
  Gets a list of all keys.
123
150
  @return { TKey }
124
151
  ]=]
125
- function ObservableMapSet:GetKeyList()
152
+ function ObservableMapSet.GetKeyList<TKey, TValue>(self: ObservableMapSet<TKey, TValue>): { TKey }
126
153
  return self._observableMapOfSets:GetKeyList()
127
154
  end
128
155
 
@@ -130,7 +157,7 @@ end
130
157
  Observes the list of all keys.
131
158
  @return Observable<{ TKey }>
132
159
  ]=]
133
- function ObservableMapSet:ObserveKeyList()
160
+ function ObservableMapSet.ObserveKeyList<TKey, TValue>(self: ObservableMapSet<TKey, TValue>): Observable.Observable<{ TKey }>
134
161
  return self._observableMapOfSets:ObserveKeyList()
135
162
  end
136
163
 
@@ -138,7 +165,7 @@ end
138
165
  Observes all keys in the map
139
166
  @return Observable<Brio<TKey>>
140
167
  ]=]
141
- function ObservableMapSet:ObserveKeysBrio()
168
+ function ObservableMapSet.ObserveKeysBrio<TKey, TValue>(self: ObservableMapSet<TKey, TValue>): Observable.Observable<_Brio.Brio<TKey>>
142
169
  return self._observableMapOfSets:ObserveKeysBrio()
143
170
  end
144
171
 
@@ -146,7 +173,7 @@ end
146
173
  Gets how many sets exist
147
174
  @return number
148
175
  ]=]
149
- function ObservableMapSet:GetSetCount()
176
+ function ObservableMapSet.GetSetCount<TKey, TValue>(self: ObservableMapSet<TKey, TValue>): number
150
177
  return self._observableMapOfSets:GetCount()
151
178
  end
152
179
 
@@ -156,7 +183,7 @@ ObservableMapSet.__len = ObservableMapSet.GetSetCount
156
183
  Observes how many sets exist
157
184
  @return Observable<number>
158
185
  ]=]
159
- function ObservableMapSet:ObserveSetCount()
186
+ function ObservableMapSet.ObserveSetCount<TKey, TValue>(self: ObservableMapSet<TKey, TValue>): Observable.Observable<number>
160
187
  return self._observableMapOfSets:ObserveCount()
161
188
  end
162
189
 
@@ -165,7 +192,10 @@ end
165
192
  @param key TKey
166
193
  @return Observable<Brio<TValue>>
167
194
  ]=]
168
- function ObservableMapSet:ObserveItemsForKeyBrio(key)
195
+ function ObservableMapSet.ObserveItemsForKeyBrio<TKey, TValue>(
196
+ self: ObservableMapSet<TKey, TValue>,
197
+ key: TKey
198
+ ): Observable.Observable<_Brio.Brio<TValue>>
169
199
  assert(key ~= nil, "Bad key")
170
200
 
171
201
  return self._observableMapOfSets:ObserveAtKeyBrio(key):Pipe({
@@ -175,19 +205,19 @@ function ObservableMapSet:ObserveItemsForKeyBrio(key)
175
205
  else
176
206
  return Rx.EMPTY
177
207
  end
178
- end);
208
+ end),
179
209
  })
180
210
  end
181
211
 
182
212
  --[=[
183
213
  Gets the first item for the given key
184
214
  @param key TKey
185
- @return TValue | nil
215
+ @return TValue?
186
216
  ]=]
187
- function ObservableMapSet:GetFirstItemForKey(key)
217
+ function ObservableMapSet.GetFirstItemForKey<TKey, TValue>(self: ObservableMapSet<TKey, TValue>, key: TKey): TValue?
188
218
  assert(key ~= nil, "Bad key")
189
219
 
190
- local observableSet = self:GetObservableSetForKey(key)
220
+ local observableSet: ObservableSet.ObservableSet<TValue> = self:GetObservableSetForKey(key) :: any
191
221
  if not observableSet then
192
222
  return nil
193
223
  end
@@ -200,7 +230,7 @@ end
200
230
  @param key TKey
201
231
  @return { TValue }
202
232
  ]=]
203
- function ObservableMapSet:GetListForKey(key)
233
+ function ObservableMapSet.GetListForKey<TKey, TValue>(self: ObservableMapSet<TKey, TValue>, key: TKey): _Table.Array<TValue>
204
234
  assert(key ~= nil, "Bad key")
205
235
 
206
236
  local observableSet = self:GetObservableSetForKey(key)
@@ -216,7 +246,10 @@ end
216
246
  @param key TKey
217
247
  @return ObservableSet<TValue>
218
248
  ]=]
219
- function ObservableMapSet:GetObservableSetForKey(key)
249
+ function ObservableMapSet.GetObservableSetForKey<TKey, TValue>(
250
+ self: ObservableMapSet<TKey, TValue>,
251
+ key: TKey
252
+ ): ObservableSet.ObservableSet<TValue>
220
253
  assert(key ~= nil, "Bad key")
221
254
 
222
255
  return self._observableMapOfSets:Get(key)
@@ -228,7 +261,12 @@ end
228
261
  @param key TKey
229
262
  @return Observable<Brio<ObservableSet<TValue>>>
230
263
  ]=]
231
- function ObservableMapSet:ObserveSetBrio(key)
264
+ function ObservableMapSet.ObserveSetBrio<TKey, TValue>(
265
+ self: ObservableMapSet<TKey, TValue>,
266
+ key: TKey
267
+ ): Observable.Observable<
268
+ _Brio.Brio<ObservableSet.ObservableSet<TValue>>
269
+ >
232
270
  assert(key ~= nil, "Bad key")
233
271
 
234
272
  return self._observableMapOfSets:ObserveAtKeyBrio(key)
@@ -240,40 +278,45 @@ end
240
278
  @param key TKey
241
279
  @return Observable<number>
242
280
  ]=]
243
- function ObservableMapSet:ObserveCountForKey(key)
244
- assert(key ~= nil, "Bad key")
281
+ function ObservableMapSet.ObserveCountForKey<TKey, TValue>(
282
+ self: ObservableMapSet<TKey, TValue>,
283
+ key: TKey
284
+ ): Observable.Observable<number>
285
+ assert((key :: any) ~= nil, "Bad key")
245
286
 
246
287
  return self:ObserveSetBrio(key):Pipe({
247
288
  RxBrioUtils.switchMapBrio(function(observableSet)
248
289
  return observableSet:ObserveCount()
249
- end);
250
- RxBrioUtils.emitOnDeath(0);
251
- })
290
+ end),
291
+ RxBrioUtils.emitOnDeath(0),
292
+ }) :: any
252
293
  end
253
294
 
254
-
255
- function ObservableMapSet:_addToSet(key, entry)
295
+ function ObservableMapSet._addToSet<TKey, TValue>(self: ObservableMapSet<TKey, TValue>, key: TKey, entry: TValue): () -> ()
256
296
  local set = self:_getOrCreateSet(key)
257
297
  return set:Add(entry)
258
298
  end
259
299
 
260
- function ObservableMapSet:_getOrCreateSet(key)
300
+ function ObservableMapSet._getOrCreateSet<TKey, TValue>(
301
+ self: ObservableMapSet<TKey, TValue>,
302
+ key: TKey
303
+ ): ObservableSet.ObservableSet<TValue>
261
304
  local existing = self._observableMapOfSets:Get(key)
262
305
  if existing then
263
306
  return existing
264
307
  end
265
308
 
266
309
  local maid = Maid.new()
267
- local set = maid:Add(ObservableSet.new(nil))
310
+ local set = maid:Add(ObservableSet.new())
268
311
 
269
312
  maid:GiveTask(set.CountChanged:Connect(function(count)
270
313
  if count <= 0 then
271
- self._maid[set] = nil
314
+ self._maid[set :: any] = nil
272
315
  end
273
316
  end))
274
317
 
275
318
  maid:GiveTask(self._observableMapOfSets:Set(key, set))
276
- self._maid[set] = maid
319
+ self._maid[set :: any] = maid
277
320
 
278
321
  return set
279
322
  end
@@ -281,10 +324,9 @@ end
281
324
  --[=[
282
325
  Cleans up the ObservableMapSet and sets the metatable to nil.
283
326
  ]=]
284
- function ObservableMapSet:Destroy()
327
+ function ObservableMapSet.Destroy<TKey, TValue>(self: ObservableMapSet<TKey, TValue>)
285
328
  self._maid:DoCleaning()
286
- setmetatable(self, nil)
329
+ setmetatable(self :: any, nil)
287
330
  end
288
331
 
289
-
290
- return ObservableMapSet
332
+ return ObservableMapSet
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  A list that can be observed for blend and other components
3
4
  @class ObservableSet
@@ -12,17 +13,31 @@ local Brio = require("Brio")
12
13
  local ValueObject = require("ValueObject")
13
14
  local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
14
15
  local DuckTypeUtils = require("DuckTypeUtils")
16
+ local _Set = require("Set")
15
17
 
16
18
  local ObservableSet = {}
17
19
  ObservableSet.ClassName = "ObservableSet"
18
20
  ObservableSet.__index = ObservableSet
19
21
 
22
+ export type ObservableSet<T> = typeof(setmetatable(
23
+ {} :: {
24
+ _maid: Maid.Maid,
25
+ _set: _Set.Set<T>,
26
+ _containsObservables: any,
27
+ _countValue: ValueObject.ValueObject<number>,
28
+ ItemAdded: Signal.Signal<T>,
29
+ ItemRemoved: Signal.Signal<T>,
30
+ CountChanged: Signal.Signal<number>,
31
+ },
32
+ ObservableSet
33
+ ))
34
+
20
35
  --[=[
21
36
  Constructs a new ObservableSet
22
37
  @return ObservableSet<T>
23
38
  ]=]
24
- function ObservableSet.new()
25
- local self = setmetatable({}, ObservableSet)
39
+ function ObservableSet.new<T>(): ObservableSet<T>
40
+ local self = setmetatable({} :: any, ObservableSet)
26
41
 
27
42
  self._maid = Maid.new()
28
43
  self._set = {}
@@ -30,7 +45,7 @@ function ObservableSet.new()
30
45
  self._containsObservables = self._maid:Add(ObservableSubscriptionTable.new())
31
46
  self._countValue = self._maid:Add(ValueObject.new(0, "number"))
32
47
 
33
- --[=[
48
+ --[=[
34
49
  Fires when an item is added
35
50
  @readonly
36
51
  @prop ItemAdded Signal<T>
@@ -38,7 +53,7 @@ function ObservableSet.new()
38
53
  ]=]
39
54
  self.ItemAdded = self._maid:Add(Signal.new())
40
55
 
41
- --[=[
56
+ --[=[
42
57
  Fires when an item is removed.
43
58
  @readonly
44
59
  @prop ItemRemoved Signal<T>
@@ -46,7 +61,7 @@ function ObservableSet.new()
46
61
  ]=]
47
62
  self.ItemRemoved = self._maid:Add(Signal.new())
48
63
 
49
- --[=[
64
+ --[=[
50
65
  Fires when the count changes.
51
66
  @prop CountChanged RBXScriptSignal
52
67
  @within ObservableSet
@@ -61,7 +76,7 @@ end
61
76
  @param value any
62
77
  @return boolean
63
78
  ]=]
64
- function ObservableSet.isObservableSet(value)
79
+ function ObservableSet.isObservableSet(value: any): boolean
65
80
  return DuckTypeUtils.isImplementation(ObservableSet, value)
66
81
  end
67
82
 
@@ -70,7 +85,7 @@ end
70
85
 
71
86
  @return (T) -> ((T, nextIndex: any) -> ...any, T?)
72
87
  ]=]
73
- function ObservableSet:__iter()
88
+ function ObservableSet.__iter<T>(self: ObservableSet<T>): typeof(pairs({} :: _Set.Set<T>))
74
89
  return pairs(self._set)
75
90
  end
76
91
 
@@ -78,43 +93,51 @@ end
78
93
  Observes all items in the set
79
94
  @return Observable<Brio<T>>
80
95
  ]=]
81
- function ObservableSet:ObserveItemsBrio()
96
+ function ObservableSet.ObserveItemsBrio<T>(self: ObservableSet<T>): Observable.Observable<Brio.Brio<T>>
82
97
  return Observable.new(function(sub)
83
98
  if not self.Destroy then
84
99
  return sub:Fail("ObservableSet is already cleaned up")
85
100
  end
86
101
 
87
102
  local maid = Maid.new()
103
+ local brios: _Set.Map<T, Brio.Brio<T>> = {}
88
104
 
89
- local function handleItem(item)
90
- if maid[item] then
105
+ local function handleItem(item: T)
106
+ if brios[item] then
91
107
  -- Happens when we're re-entrance
92
108
  return
93
109
  end
94
110
 
95
111
  local brio = Brio.new(item)
96
- maid[item] = brio
112
+ brios[item] = brio :: any
97
113
  sub:Fire(brio)
98
114
  end
99
115
 
100
-
101
116
  maid:GiveTask(self.ItemAdded:Connect(handleItem))
102
- maid:GiveTask(self.ItemRemoved:Connect(function(item)
103
- maid[item] = nil
117
+ maid:GiveTask(self.ItemRemoved:Connect(function(item: T)
118
+ if brios[item] then
119
+ local brio = brios[item]
120
+ brios[item] = nil
121
+
122
+ brio:Destroy()
123
+ end
104
124
  end))
105
125
 
106
- for item, _ in pairs(self._set) do
126
+ for item, _ in self._set do
107
127
  handleItem(item)
108
128
  end
109
129
 
110
- self._maid[sub] = maid
130
+ self._maid[sub :: any] = maid
111
131
  maid:GiveTask(function()
112
- self._maid[sub] = nil
132
+ for _, brio: any in brios do
133
+ brio:Destroy()
134
+ end
135
+ self._maid[sub :: any] = nil
113
136
  sub:Complete()
114
137
  end)
115
138
 
116
139
  return maid
117
- end)
140
+ end) :: any
118
141
  end
119
142
 
120
143
  --[=[
@@ -124,7 +147,7 @@ end
124
147
  @param item T
125
148
  @return Observable<boolean>
126
149
  ]=]
127
- function ObservableSet:ObserveContains(item)
150
+ function ObservableSet.ObserveContains<T>(self: ObservableSet<T>, item: T): Observable.Observable<boolean>
128
151
  assert(item ~= nil, "Bad item")
129
152
 
130
153
  return Observable.new(function(sub)
@@ -144,14 +167,14 @@ function ObservableSet:ObserveContains(item)
144
167
  sub:Fire(doesContain)
145
168
  end))
146
169
 
147
- self._maid[sub] = maid
170
+ self._maid[sub :: any] = maid
148
171
  maid:GiveTask(function()
149
- self._maid[sub] = nil
172
+ self._maid[sub :: any] = nil
150
173
  sub:Complete()
151
174
  end)
152
175
 
153
176
  return maid
154
- end)
177
+ end) :: any
155
178
  end
156
179
 
157
180
  --[=[
@@ -159,7 +182,7 @@ end
159
182
  @param item T
160
183
  @return boolean
161
184
  ]=]
162
- function ObservableSet:Contains(item)
185
+ function ObservableSet.Contains<T>(self: ObservableSet<T>, item: T): boolean
163
186
  assert(item ~= nil, "Bad item")
164
187
 
165
188
  return self._set[item] == true
@@ -169,7 +192,7 @@ end
169
192
  Gets the count of items in the set
170
193
  @return number
171
194
  ]=]
172
- function ObservableSet:GetCount()
195
+ function ObservableSet.GetCount<T>(self: ObservableSet<T>): number
173
196
  return self._countValue.Value or 0
174
197
  end
175
198
 
@@ -179,7 +202,7 @@ ObservableSet.__len = ObservableSet.GetCount
179
202
  Observes the count of the set
180
203
  @return Observable<number>
181
204
  ]=]
182
- function ObservableSet:ObserveCount()
205
+ function ObservableSet.ObserveCount<T>(self: ObservableSet<T>): Observable.Observable<number>
183
206
  return self._countValue:Observe()
184
207
  end
185
208
 
@@ -188,7 +211,7 @@ end
188
211
  @param item T
189
212
  @return callback -- Call to remove
190
213
  ]=]
191
- function ObservableSet:Add(item)
214
+ function ObservableSet.Add<T>(self: ObservableSet<T>, item: T): () -> ()
192
215
  assert(item ~= nil, "Bad item")
193
216
 
194
217
  if not self._set[item] then
@@ -210,8 +233,9 @@ end
210
233
  --[=[
211
234
  Removes the item from the set if it exists.
212
235
  @param item T
236
+ @return True if removed
213
237
  ]=]
214
- function ObservableSet:Remove(item)
238
+ function ObservableSet.Remove<T>(self: ObservableSet<T>, item: T): boolean
215
239
  assert(item ~= nil, "Bad item")
216
240
 
217
241
  if self._set[item] then
@@ -223,6 +247,9 @@ function ObservableSet:Remove(item)
223
247
  self.ItemRemoved:Fire(item)
224
248
  end
225
249
  self._countValue.Value = self._countValue.Value - 1
250
+ return true
251
+ else
252
+ return false
226
253
  end
227
254
  end
228
255
 
@@ -230,7 +257,7 @@ end
230
257
  Gets an arbitrary item in the set (not guaranteed to be ordered)
231
258
  @return T
232
259
  ]=]
233
- function ObservableSet:GetFirstItem()
260
+ function ObservableSet.GetFirstItem<T>(self: ObservableSet<T>): T?
234
261
  local value = next(self._set)
235
262
  return value
236
263
  end
@@ -239,9 +266,9 @@ end
239
266
  Gets a list of all entries.
240
267
  @return { T }
241
268
  ]=]
242
- function ObservableSet:GetList()
269
+ function ObservableSet.GetList<T>(self: ObservableSet<T>): { T }
243
270
  local list = table.create(self._countValue.Value)
244
- for item, _ in pairs(self._set) do
271
+ for item, _ in self._set do
245
272
  table.insert(list, item)
246
273
  end
247
274
  return list
@@ -251,7 +278,7 @@ end
251
278
  Gets a copy of the set
252
279
  @return { [T]: true }
253
280
  ]=]
254
- function ObservableSet:GetSetCopy()
281
+ function ObservableSet.GetSetCopy<T>(self: ObservableSet<T>): _Set.Set<T>
255
282
  return table.clone(self._set)
256
283
  end
257
284
 
@@ -259,7 +286,7 @@ end
259
286
  Gets the raw set. Do not modify this set.
260
287
  @return { [T]: true }
261
288
  ]=]
262
- function ObservableSet:GetRawSet()
289
+ function ObservableSet.GetRawSet<T>(self: ObservableSet<T>): _Set.Set<T>
263
290
  return self._set
264
291
  end
265
292
 
@@ -267,9 +294,9 @@ end
267
294
  --[=[
268
295
  Cleans up the ObservableSet and sets the metatable to nil.
269
296
  ]=]
270
- function ObservableSet:Destroy()
297
+ function ObservableSet.Destroy<T>(self: ObservableSet<T>)
271
298
  self._maid:DoCleaning()
272
- setmetatable(self, nil)
299
+ setmetatable(self :: any, nil)
273
300
  end
274
301
 
275
302
  return ObservableSet