1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 10:07:02 +00:00

ui: impl Timer.schedule function

This commit is contained in:
James Hillyerd
2020-04-05 17:27:22 -07:00
parent e8e506f870
commit 4fc8d229eb
2 changed files with 13 additions and 6 deletions

View File

@@ -1,9 +1,11 @@
module Timer exposing (Timer, cancel, empty, replace)
module Timer exposing (Timer, cancel, empty, replace, schedule)
import Process
import Task
{-| Implements an identity to track an asynchronous timer.
-}
type Timer
= Empty
| Idle Int
@@ -15,6 +17,11 @@ empty =
Empty
schedule : (Timer -> msg) -> Timer -> Float -> Cmd msg
schedule message timer millis =
Task.perform (always (message timer)) (Process.sleep millis)
{-| Replaces the provided timer with a newly created one.
-}
replace : Timer -> Timer