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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user