Just released a new version of elm-delay - a small set of utils for sequencing messages after given intervals.
Myself and a few others were only really using milliseconds as a time unit, so the main change was to use milliseconds as a default to make the api a bit cleaner:
before:
Delay.after 500 Milliseconds MessageTriggered
now:
Delay.after 500 MessageTriggered
There are some helpers to convert units for readability / backwards compatibility
Very nice update! I’m curious why you’ve chosen Millis -> Millis for seconds, minutes, and hours… I understand that it’s all Int under the hood but the docs read oddly.
Going further, is there any reason that withUnit must take Millis/Ints? You could have:
withUnit : (unit -> Millis) -> List ( unit, msg ) -> List ( Millis, msg )
Then consumers could use any units they like, including elm-units or custom types, for example:
type DelayUnit
= Short
| Long
delayTime : DelayUnit -> Delay.Millis
delayTime delay =
case delay of
Short ->
500
Long ->
5000
--
Delay.after (delayTime Long) MessageTriggered
Delay.sequence
(Delay.withUnit delayTime
[ ( Short, FirstMessage )
, ( Long, SecondMessage )
, ( Short, ThirdMessage )
]
)
For seconds and minutes those were really for compatibility with the older version (I don’t personally use them and I wonder who does ), there is a typealias ToUnit for those definitions but it doesn’t look like function typealiases show up in the elm docs elm-delay/Delay.elm at main · andrewMacmurray/elm-delay · GitHub
I’d be tempted to get rid of these but would be nice to get some feedback from anyone using this - I’d also be super curious to know who actually uses this package and what for!
I like your suggestion for withUnit, will change to that in the next release