fix: wrap initial run in peek()

This commit is contained in:
Richard 2025-01-25 11:49:19 -08:00
parent 052f9aaa31
commit 24348f9c24
2 changed files with 6 additions and 2 deletions

View file

@ -61,7 +61,9 @@ local function mapped<K0, V0, K1, V1>(callback: Selector<{ [K0]: V0 }>, mapper:
unsubscribe = subscribe(callback, listener)
listener(store.peek(callback))
store.peek(function(): ()
listener(callback())
end)
return mappedAtom
end

View file

@ -34,7 +34,9 @@ local function observe<K, V>(callback: Selector<{ [K]: V }>, factory: (value: V,
local unsubscribe = subscribe(callback, listener)
listener(store.peek(callback))
store.peek(function(): ()
listener(callback())
end)
return function()
unsubscribe()