Sorry, old habits. The Http API became Cmd oriented. You don't need Task.attempt. Just use the regular Http.get and use the Cmds produced by it.
If you need chaining, there is a `toTask` function that converts Requests to Tasks On Wed, Nov 16, 2016 at 3:33 PM, Tim Bezhashvyly <[email protected]> wrote: > Thank. This makes lots of sense in regards of first argument. > > What about the second? In 0.17 it could be for example: > > (Http.get "my.json" decoderFunction) > > But not it produced an error: > > Function `attempt` is expecting the 2nd argument to be: Task.Task >> Http.Error (Maybe MyType) But it is: Http.Request MyType > > > > On Wednesday, November 16, 2016 at 2:22:48 PM UTC+1, Peter Damoc wrote: >> >> The old Task.perform was creating either a success message (if it >> succeeded) or a fail message (if it failed) >> The current Task.perform cannot fail. It is used for Tasks that are known >> to succeed like requesting the window size or requesting some random >> number. >> >> The Task.attempt takes a function that takes a result (results >> encapsulate both the success and the failure) and produces a message based >> on that result. >> >> You could define something like: >> >> handleRequest result = >> case result of >> Ok val -> >> SuccessMessage val >> Err err -> >> FailMessage err >> >> and use it like this: >> >> someHttpCmd = Task.attempt handleRequest someHttpRequestTask >> >> Alternatively, you could just have only one message that takes a Result >> and handle each case in that message's part of the update as demonstrated >> by the Http example: >> http://elm-lang.org/examples/http >> >> >> >> >> On Wed, Nov 16, 2016 at 3:05 PM, Tim Bezhashvyly <[email protected]> >> wrote: >> >>> Sorry again if something obvious but Im not sure how now to make async >>> requests in 0.18.0. >>> >>> In 0.17.1 it was done with Task.perform where first parameter was a >>> success Msg, second - fail Msg and third is the task which execution result >>> is then passed to first function. >>> >>> As far as I understand now Task.attempt must be used but documentation >>> is not quite comprehensive. Could someone please advise? >>> >>> -- >>> 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. >>> >> >> >> >> -- >> There is NO FATE, we are the creators. >> blog: http://damoc.ro/ >> > -- > 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. > -- There is NO FATE, we are the creators. blog: http://damoc.ro/ -- 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.
