krisajenkins / remotedata

Tools for fetching data from remote sources (incl. HTTP).
MIT License
249 stars 23 forks source link

Update to new elm/http 2.0 API #30

Closed dawehner closed 5 years ago

dawehner commented 5 years ago

Elm/http got updated to a new API.

Before

 Http.send LoadMetadata (Http.getString "https://example.com/books/war-and-peace")

After

 Http.get {
  url =  "https://example.com/books/war-and-peace"
  , expect = Http.expectString LoadMetadata
 }

The most dramatic change is that there is no longer a request object. For custom requests, there is still Http.request

Sadly this mean RemoteData.sendRequest no longer works.

Possible new RemoteData api

  1. Mirror the HTTP 2.0 api:
    RemoteData.get
    RemoteData.post
    RemoteData.request
    ...
  2. Provide a more HTTP 1.0 api:
    RemoteData.get |> RemoteData.sendRequest
    RemoteData.post |> RemoteData.sendRequest
    ...

@krisajenkins Do you have any thoughts?

dawehner commented 5 years ago

I've tried to give this a try, but I struggled to deal with with "expect". I don't really see a way to map expectString, expectJson etc.

I've pushed the branch. While RemoteData itself compiles I'm not sure how to get it to compile for the actual app, see the example folder.

netaisllc commented 5 years ago

@dawehner To me, it looks like this commit: a849c24dc622b57b852a124d3d067545e35a697a brings RemoteData into alignment with the new elm/http@2.0.0.

Looking at the package docs and source code there's no trace of sendRequest

🥇 Thanks to the package maintainers - all hail!

krisajenkins commented 5 years ago

This was addressed by PR #29 and published as 6.0.0. :-)

dawehner commented 5 years ago

Sure :) I wanted to though provide an API which is more similar to the official API of elm/http and not rely on people having to use tasks. To be fair, it is something one could argue which would be worth knowing for people.