I'm struggling to compose two tasks.  Specifically, I'm making an HTTP
request, but I also want to know the time the http request was executed.

I have the following code:

type Msg =
    Refresh
  | Success Time Documents
  | Failed Time Http.Error

requestDocuments : Cmd Msg
requestDocuments =
  Task.perform (Failed 0) (Success 0) <| httpInvoke documentsDecoder
"/collections/dashboard-alerts/keys"

httpInvoke : JsonDecode.Decoder value -> String -> Task.Task Http.Error
value
httpInvoke decoder path =
  let
    request = {
      verb = "GET",
      headers = [ ("Authorization", "Basic SNIP") ],
      url = ("https://SNIP/1"; ++ path),
      body = Http.empty
    }
  in
    Http.fromJson decoder <| Http.send Http.defaultSettings request

You can see I'm trying generate the Success/Failed messages that both
should include a time but for the moment I'm simply injecting a value of
zero.

It seems like I should use Task.andThen or Task.map or something similar to
compose httpInvoke with Time.now, but I'm really struggling to pull this
together and tie it into Task.perform.

Could somebody help?

Thanks!
Bryan

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to