Elm-delay 4.0.0

Hi Folks,

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

Delay.after (Delay.seconds 1) MessageTriggered

Shoutout to @lenards for their contributions!

Checkout the library here: elm-delay 4.0.0

9 Likes

Thanks Andrew! Glad to help. I appreciate your contribution/work on this library!

2 Likes

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 )
        ]
    )

Thanks @sparksp those are some very good points.

For seconds and minutes those were really for compatibility with the older version (I don’t personally use them and I wonder who does :man_shrugging:), 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 :+1:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.