On Tuesday, April 4, 2017 at 2:39:07 PM UTC+1, Richard Wood wrote:
>
> Hi Rupert
> Thanks for that, here's where I ended up, not properly tested yet: 
> setTokenCheck : Model -> Cmd Msg
> setTokenCheck model =
>     setTimeCheck model.theTime
>         (Auth.tokenExpiryTime model.authenticationModel)
>         TokenCheck
>
>
> setTimeCheck : Time -> Time -> Msg -> Cmd Msg
> setTimeCheck theTime expiryTime msg =
>     let
>         duration =
>             Basics.max 0 (expiryTime - theTime)
>     in
>         Time.now
>             |> Task.andThen (\now -> Process.sleep duration)
>             |> Task.attempt (\_ -> msg)
>
>
>
> Can you tell me what this code is in your code: 
> delay refreshDate now =
> max 0 ((Date.toTime refreshDate) - now)
>
> What sort of thing is delay, a function or a variable? 
>

'delay' is a function. It takes the time 'refreshDate' that I want to 
refresh my token at, and the time 'now', and calculates a delay from those 
2 to pass to the Process.sleep function. I used 'max 0' to ensure that this 
delay never goes below zero, which might happen if the refresh time had 
already passed. 

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