Skip to content

Instantly share code, notes, and snippets.

@Luiz-Monad
Created September 13, 2019 19:00
Show Gist options
  • Save Luiz-Monad/5bf2b19a82593699e1fe9c2d67ef689d to your computer and use it in GitHub Desktop.
Save Luiz-Monad/5bf2b19a82593699e1fe9c2d67ef689d to your computer and use it in GitHub Desktop.
Delayed computation example
msg {
let! xn = ApiSubmit ( API.GetWorker )
match xn with
//match! User.Get with
| Ok data ->
yield StorageSave ( DataKey.User, data )
| Error (e: FableUtil.FetchUtil.Response) ->
yield ApplicationError <| string e.Status + " " + e.StatusText
match loadUser () with
| Some user ->
yield user |> UserIndex.Message.Load |> PageMsg.UserIndex |> PageMessage
| _ -> ()
}
//somewhere else in a global message loop
| Continuation ( ( APICall apiModel ), next ), _ ->
model
, Cmd.OfPromise.either API.submit apiModel
( fun _ -> next )
( fun e -> alert "Erro" e.Message )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment