refactor!: design overhaul (#1)

* refactor!: use atom functions

* docs: reformat api reference

* docs: showcase atom functions

* docs: remove unused import

* refactor: finalize updates

* chore: misc edits
This commit is contained in:
richard 2024-03-25 19:53:28 -07:00 • committed by GitHub
parent 4d4979daa9
commit 33ecae2f50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 577 additions and 729 deletions

View file

@ -6,7 +6,7 @@ return function()
local itemsAtom = atom({ "a", "b", "c" })
local state = {}
local cleanup, flush = observe(itemsAtom, function(item, key)
local cleanup = observe(itemsAtom, function(item, key)
state[key] = item
return function()
state[key] = nil
@ -14,14 +14,13 @@ return function()
end)
for key = 1, 3 do
expect(state[key]).to.equal(itemsAtom:get()[key])
expect(state[key]).to.equal(itemsAtom()[key])
end
itemsAtom:set({ [4] = "d", [5] = "e", [6] = "f" })
flush()
itemsAtom({ [4] = "d", [5] = "e", [6] = "f" })
for key = 1, 6 do
expect(state[key]).to.equal(itemsAtom:get()[key])
expect(state[key]).to.equal(itemsAtom()[key])
end
cleanup()