mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
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:
parent
4d4979daa9
commit
33ecae2f50
39 changed files with 577 additions and 729 deletions
22
src/effect.luau
Normal file
22
src/effect.luau
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local capture = require(script.Parent.capture)
|
||||
local store = require(script.Parent.store)
|
||||
|
||||
local function effect(source: () -> nil): () -> ()
|
||||
local atoms = capture(source)
|
||||
|
||||
local function listener()
|
||||
source()
|
||||
end
|
||||
|
||||
for atom in atoms do
|
||||
store.listeners[atom][listener] = true
|
||||
end
|
||||
|
||||
return function()
|
||||
for atom in atoms do
|
||||
store.listeners[atom][listener] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return effect
|
||||
Loading…
Add table
Add a link
Reference in a new issue