mirror of
https://github.com/littensy/charm.git
synced 2026-10-23 22:21:37 +00:00
feat: add effect cleanups, add docs (#2)
* docs: update readme * feat: add cleanup function to effects * refactor: move peek function to store module * test: add nested atom check * docs: add doc comments * fix: `effect()` type * refactor: remove divider comment
This commit is contained in:
parent
1a65a4a0de
commit
6a9c580bd7
24 changed files with 805 additions and 76 deletions
|
|
@ -5,6 +5,15 @@ type Atom<T> = types.Atom<T>
|
|||
type AtomOptions<T> = types.AtomOptions<T>
|
||||
type Molecule<T> = types.Molecule<T>
|
||||
|
||||
--[=[
|
||||
Creates a read-only atom that derives its state from one or more atoms.
|
||||
Used to avoid unnecessary recomputations if multiple listeners depend on
|
||||
the same molecule.
|
||||
|
||||
@param molecule The function that produces the state.
|
||||
@param options Optional configuration.
|
||||
@return A new read-only atom.
|
||||
]=]
|
||||
local function computed<T>(molecule: Molecule<T>, options: AtomOptions<T>?): Molecule<T>
|
||||
local captured, state = store.capture(molecule)
|
||||
local computedAtom = atom(state, options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue