mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
chore: update eslint, housekeeping
This commit is contained in:
parent
cb52ece4d3
commit
4a07297a13
14 changed files with 554 additions and 619 deletions
|
|
@ -5,14 +5,14 @@ local subscribe = Charm.subscribe
|
|||
local source = Vide.source
|
||||
local cleanup = Vide.cleanup
|
||||
|
||||
--- Subscribes to the state of an atom or selector. Returns a source that
|
||||
--- updates when the state changes.
|
||||
--- Returns a reactive source that updates when the given getter function's
|
||||
--- value changes.
|
||||
---
|
||||
--- @param callback The atom or selector to subscribe to.
|
||||
--- @param getter The atom or selector to subscribe to.
|
||||
--- @return The reactive source.
|
||||
local function useAtom<State>(callback: () -> State): () -> State
|
||||
local state = source(callback())
|
||||
cleanup(subscribe(callback, state))
|
||||
local function useAtom<State>(getter: () -> State): () -> State
|
||||
local state = source(getter())
|
||||
cleanup(subscribe(getter, state))
|
||||
return state
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue