mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 19:54:09 +00:00
refactor: remove unnecessary features, update docs
This commit is contained in:
parent
7a88c784fa
commit
37f79ecc3f
20 changed files with 774 additions and 955 deletions
|
|
@ -1,12 +1,12 @@
|
|||
local Charm = require("./Charm")
|
||||
local Vide = require("./Vide")
|
||||
|
||||
--- Returns a reactive source that updates when the given getter function's
|
||||
--- value changes.
|
||||
--- Returns a reactive source that subscribes to the current value of the given
|
||||
--- signal or getter function.
|
||||
---
|
||||
--- @param getter The atom or selector to subscribe to.
|
||||
--- @param getter The getter function to subscribe to.
|
||||
--- @return The reactive source.
|
||||
local function useAtom<State>(getter: () -> State): () -> State
|
||||
local function useSignalState<State>(getter: () -> State): () -> State
|
||||
local state = Vide.source(getter())
|
||||
|
||||
Vide.cleanup(Charm.effect(function()
|
||||
|
|
@ -18,5 +18,6 @@ local function useAtom<State>(getter: () -> State): () -> State
|
|||
end
|
||||
|
||||
return {
|
||||
useAtom = useAtom,
|
||||
useSignalState = useSignalState,
|
||||
useAtom = useSignalState,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue