@rbxts/covenant 3.7.0 → 3.7.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.
- package/package.json +1 -1
- package/src/hooks.d.ts +0 -4
- package/src/hooks.luau +0 -59
package/package.json
CHANGED
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
|
@@ -133,64 +133,6 @@ local function createUseComponentChange(_param)
|
|
|
133
133
|
return queue
|
|
134
134
|
end
|
|
135
135
|
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
136
|
local function equalsDependencies(a, b)
|
|
195
137
|
if a == b then
|
|
196
138
|
return true
|
|
@@ -423,7 +365,6 @@ local function createHooks(props)
|
|
|
423
365
|
useEvent = createUseEvent(props),
|
|
424
366
|
useEventImmediately = createUseEventImmediately(props),
|
|
425
367
|
useComponentChange = createUseComponentChange(props),
|
|
426
|
-
useComponentChangeOfEntity = createUseComponentChangeOfEntity(props),
|
|
427
368
|
useAsync = createUseAsync(props),
|
|
428
369
|
useImperative = createUseImperative(props),
|
|
429
370
|
useChange = createUseChange(),
|