fix: avoid reconnecting to dependencies after cleanup (#14)

* fix: cancel reconnection when unsubscribing

* test: remove print

* feat: allow factory to return nil

* perf: use `next` iteration
This commit is contained in:
richard 2024-07-10 15:13:36 -07:00 • committed by GitHub
parent 62be3e496d
commit c6762a6525
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 87 additions and 63 deletions

View file

@ -13,7 +13,7 @@ end
local function diff(prevState: { [any]: any }, nextState: { [any]: any })
local patches = table.clone(nextState)
for key, previous in prevState do
for key, previous in next, prevState do
local next = nextState[key]
if previous == next then
@ -26,7 +26,7 @@ local function diff(prevState: { [any]: any }, nextState: { [any]: any })
end
if _G.__DEV__ then
for key, value in prevState do
for key, value in next, prevState do
validate(value, key)
end
@ -50,7 +50,7 @@ local function apply(state: any, patches: any): any
local nextState = table.clone(state)
local stateIsArray = state[1] ~= nil
for key, patch in patches do
for key, patch in next, patches do
-- Diff-checking an array produces a sparse array, which will not be
-- preserved when converted to JSON. To prevent this, we turn string
-- keys back into numeric keys.