mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 21:01:38 +00:00
fix: wrap initial run in peek()
This commit is contained in:
parent
052f9aaa31
commit
24348f9c24
2 changed files with 6 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue