refactor: rename unwrap to peek

This commit is contained in:
Richard 2024-04-23 20:35:42 -07:00
parent 1e7e20902a
commit 047be71eaa
6 changed files with 16 additions and 16 deletions

View file

@ -1,8 +1,8 @@
local peek = require(script.Parent.peek)
local store = require(script.Parent.store)
local types = require(script.Parent.types)
type Atom<T> = types.Atom<T>
type AtomOptions<T> = types.AtomOptions<T>
local unwrap = require(script.Parent.unwrap)
local function atom<T>(state: T, options: AtomOptions<T>?): Atom<T>
local equals = options and options.equals
@ -17,7 +17,7 @@ local function atom<T>(state: T, options: AtomOptions<T>?): Atom<T>
end
-- Atoms called in a function should not be a part of the dependency tree
local nextState = unwrap(..., state)
local nextState = peek(..., state)
if state ~= nextState and not (equals and equals(state, nextState)) then
state = nextState