mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
test: add benchmarks, dev mode
This commit is contained in:
parent
3548ca5c58
commit
4586882d3c
6 changed files with 95 additions and 11 deletions
|
|
@ -1,15 +1,10 @@
|
|||
local reference = require(script.Parent.utils.reference)
|
||||
|
||||
type AtomInternal<T> = {
|
||||
--- @deprecated
|
||||
setForced: (self: AtomInternal<T>, state: T | ((T) -> T)) -> (),
|
||||
--- @deprecated
|
||||
listeners: { [(T) -> ()]: true },
|
||||
--- @deprecated
|
||||
debugTraceback: string,
|
||||
--- @deprecated
|
||||
debugLabel: string,
|
||||
--- @deprecated
|
||||
owners: { [any]: true },
|
||||
}
|
||||
|
||||
|
|
@ -63,10 +58,10 @@ local function atom<State>(state: State): Atom<State>
|
|||
if setter then
|
||||
local result = setter(nextState, state)
|
||||
|
||||
if result == nil then
|
||||
return
|
||||
else
|
||||
if result ~= nil then
|
||||
nextState = result
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -103,7 +98,9 @@ local function atom<State>(state: State): Atom<State>
|
|||
|
||||
function atom:readonly(): ReadonlyAtom<State>
|
||||
function setter(_, _)
|
||||
error(`Attempt to set read-only atom '{label}' created at: {traceback}`, 3)
|
||||
if _G.__DEV__ then
|
||||
error(`Attempt to set read-only atom '{label}' created at: {traceback}`, 3)
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue