On Wednesday, November 9, 2016 at 10:22:05 AM UTC, Rupert Smith wrote:
>
> Or can I chain Time.now andThen Process.sleep andThen invokeRefresh 
> together without needing to issue a Cmd and have and update handler for the 
> intermediate steps? I'll look into that. 
>

Chaining the tasks together turned out to be fairly easy once I got my head 
around it:

tokenExpiryTask : Date -> Task.Task Http.Error Model.AuthResponse
tokenExpiryTask refreshDate =
    let
        delay expiryDate now =
            max 0 ((Date.toTime expiryDate) - now - Time.second * 30)
    in
        Time.now
            `andThen` (\now -> Process.sleep <| delay refreshDate now)
            `andThen` (\_ -> Auth.Service.refreshTask)
 
Thanks for the pointers in the right direction.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to