mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51: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
|
|
@ -3,6 +3,18 @@ local subscribe = require(script.Parent.Parent.subscribe)
|
|||
local types = require(script.Parent.Parent.types)
|
||||
type Molecule<T> = types.Molecule<T>
|
||||
|
||||
--[=[
|
||||
A hook that subscribes to changes in the given atom or molecule. The
|
||||
component is re-rendered whenever the state changes.
|
||||
|
||||
If the `dependencies` array is provided, the subscription to the atom or
|
||||
molecule is re-created whenever the dependencies change. Otherwise, the
|
||||
subscription is created once when the component is mounted.
|
||||
|
||||
@param molecule The atom or molecule to subscribe to.
|
||||
@param dependencies An array of values that the subscription depends on.
|
||||
@return The current state.
|
||||
]=]
|
||||
local function useAtom<State>(molecule: Molecule<State>, dependencies: { any }?): State
|
||||
local React = requireReact()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue