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

@ -36,7 +36,7 @@ local function mapped<K0, V0, K1, V1>(molecule: Molecule<{ [K0]: V0 }>, mapper:
local mappedKeys = {}
-- TODO: Only call mapper if the item has changed.
for key, item in items do
for key, item in next, items do
local newItem, newKey = mapper(item, key)
if newKey == nil then
newKey = key :: any
@ -48,7 +48,7 @@ local function mapped<K0, V0, K1, V1>(molecule: Molecule<{ [K0]: V0 }>, mapper:
end
end
for key in prevMappedItems do
for key in next, prevMappedItems do
if mappedKeys[key] == nil and mappedItems[key] == prevMappedItems[key] then
mappedItems[key] = nil
end