Skip to content

Commit

Permalink
Dispose correctly the cancellation token
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Jan 29, 2024
1 parent 9edb16b commit 484d729
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Fabulous.Tests/CmdTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ type ``Cmd tests``() =
do! Async.Sleep 125

Assert.AreEqual(Some(NewValue 3), actualValue)

actualValue <- None

triggerCmd 4 |> CmdTestsHelper.execute dispatch
do! Async.Sleep 75
triggerCmd 5 |> CmdTestsHelper.execute dispatch
do! Async.Sleep 125

Assert.AreEqual(Some(NewValue 5), actualValue)
}
3 changes: 3 additions & 0 deletions src/Fabulous/Cmd.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ module Cmd =
async {
do! Async.Sleep(timeout)
dispatch(fn value)

cts.Dispose()
cts <- null
},
cts.Token
) ]

0 comments on commit 484d729

Please sign in to comment.