mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
feat: prepare for alpha release
This commit is contained in:
parent
5a05f01223
commit
f5709c3112
10 changed files with 251 additions and 54 deletions
|
|
@ -1,18 +1,18 @@
|
|||
local Charm = require("./Charm")
|
||||
local Vide = require("./Vide")
|
||||
|
||||
local subscribe = Charm.subscribe
|
||||
local source = Vide.source
|
||||
local cleanup = Vide.cleanup
|
||||
|
||||
--- Returns a reactive source that updates when the given getter function's
|
||||
--- value changes.
|
||||
---
|
||||
--- @param getter The atom or selector to subscribe to.
|
||||
--- @return The reactive source.
|
||||
local function useAtom<State>(getter: () -> State): () -> State
|
||||
local state = source(getter())
|
||||
cleanup(subscribe(getter, state))
|
||||
local state = Vide.source(getter())
|
||||
|
||||
Vide.cleanup(Charm.effect(function()
|
||||
state(getter())
|
||||
end))
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue