feat: initial commit

This commit is contained in:
Richard 2024-02-25 03:41:09 -08:00
commit 18723c1377
50 changed files with 3238 additions and 0 deletions

19
src/react/useAtom.luau Normal file
View file

@ -0,0 +1,19 @@
local atom = require(script.Parent.Parent.atom)
type Atom<T> = atom.Atom<T>
local useAtomState = require(script.Parent.useAtomState)
local useSetAtom = require(script.Parent.useSetAtom)
type UseAtom =
(<State>(atom: Atom<State>) -> (State, useSetAtom.SetState<State>))
& (<State, Result>(
atom: Atom<State>,
selector: ((State) -> Result)?
) -> (State | Result, useSetAtom.SetState<State | Result>))
& (<State, Result>(atom: Atom<State>, selector: (State) -> Result) -> (Result, useSetAtom.SetState<State>))
local function useAtom<State>(atom: Atom<State>, selector: ((State) -> State)?): (State, useSetAtom.SetState<State>)
return useAtomState(atom, selector), useSetAtom(atom)
end
return useAtom :: UseAtom