@rbxts/covenant 3.7.0 → 3.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/covenant",
3
- "version": "3.7.0",
3
+ "version": "3.7.2",
4
4
  "main": "src/init.luau",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",
package/src/hooks.d.ts CHANGED
@@ -14,10 +14,6 @@ export interface CovenantHooks {
14
14
  state: T | undefined;
15
15
  previousState: T | undefined;
16
16
  }[];
17
- useComponentChangeOfEntity: <T extends defined>(updateId: number, entity: Entity, component: Entity<T>, payload: boolean) => {
18
- state: T | undefined;
19
- previousState: T | undefined;
20
- } | undefined;
21
17
  useAsync: <T>(updateId: number, asnycFactory: () => T, dependencies: unknown[], discriminator: Discriminator) => AsyncResult<T>;
22
18
  useImperative: <T extends defined>(updateId: number, dirtyFactory: (indicateUpdate: () => void) => {
23
19
  value: T;
package/src/hooks.luau CHANGED
@@ -22,13 +22,16 @@ local function createUseEvent(_param)
22
22
  if not watchedEvents:has(instance, event) then
23
23
  watchedEvents:add(instance, event)
24
24
  queues:set(instance, event, {})
25
- event:Connect(function(...)
25
+ local connection = event:Connect(function(...)
26
26
  local args = { ... }
27
27
  local _exp = queues:get(instance, event)
28
28
  local _args = args
29
29
  table.insert(_exp, _args)
30
30
  indicateUpdate()
31
31
  end)
32
+ instance.Destroying:Once(function()
33
+ connection:Disconnect()
34
+ end)
32
35
  caches:set(instance, event, {})
33
36
  return {}
34
37
  end
@@ -133,64 +136,6 @@ local function createUseComponentChange(_param)
133
136
  return queue
134
137
  end
135
138
  end
136
- local function createUseComponentChangeOfEntity(_param)
137
- local covenant = _param.covenant
138
- local indicateUpdate = _param.indicateUpdate
139
- local changes = {}
140
- local watchedStringifiedComponents = {}
141
- local caches = {}
142
- local lastUpdateId = -1
143
- return function(updateId, entity, component, payload)
144
- if payload == nil then
145
- payload = false
146
- end
147
- if lastUpdateId ~= updateId then
148
- table.clear(caches)
149
- lastUpdateId = updateId
150
- end
151
- local stringifiedComponent = tostring(component)
152
- local cache = caches[stringifiedComponent]
153
- if cache ~= nil then
154
- return if cache == false then nil else cache
155
- end
156
- if not (watchedStringifiedComponents[stringifiedComponent] ~= nil) then
157
- watchedStringifiedComponents[stringifiedComponent] = true
158
- covenant:subscribeComponent(component, function(anEntity, state, previousState)
159
- if entity ~= anEntity then
160
- return nil
161
- end
162
- local _arg1 = {
163
- state = state,
164
- previousState = previousState,
165
- }
166
- changes[stringifiedComponent] = _arg1
167
- indicateUpdate()
168
- end)
169
- caches[stringifiedComponent] = false
170
- if not payload then
171
- return nil
172
- else
173
- if not covenant:worldContains(entity) then
174
- return nil
175
- end
176
- local state = covenant:worldGet(entity, component)
177
- if state == nil then
178
- return nil
179
- end
180
- return {
181
- state = state,
182
- previousState = nil,
183
- }
184
- end
185
- end
186
- local change = changes[stringifiedComponent]
187
- if change ~= nil then
188
- changes[stringifiedComponent] = nil
189
- end
190
- caches[stringifiedComponent] = change
191
- return change
192
- end
193
- end
194
139
  local function equalsDependencies(a, b)
195
140
  if a == b then
196
141
  return true
@@ -423,7 +368,6 @@ local function createHooks(props)
423
368
  useEvent = createUseEvent(props),
424
369
  useEventImmediately = createUseEventImmediately(props),
425
370
  useComponentChange = createUseComponentChange(props),
426
- useComponentChangeOfEntity = createUseComponentChangeOfEntity(props),
427
371
  useAsync = createUseAsync(props),
428
372
  useImperative = createUseImperative(props),
429
373
  useChange = createUseChange(),