mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
feat: pass cleanup function to effect (#40)
This commit is contained in:
parent
6be2fbb746
commit
89f1dfeaa5
3 changed files with 35 additions and 11 deletions
|
|
@ -93,4 +93,19 @@ return function()
|
|||
a(2)
|
||||
a(3)
|
||||
end)
|
||||
|
||||
it("allows immediate self-cleanup", function()
|
||||
local a = atom(1)
|
||||
local cleanedUp = false
|
||||
|
||||
effect(function(cleanup)
|
||||
assert(not cleanedUp, "cleanup ran twice")
|
||||
cleanup()
|
||||
cleanedUp = true
|
||||
a()
|
||||
end)
|
||||
|
||||
a(2)
|
||||
a(3)
|
||||
end)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue