rescript-webapi
rescript-webapi copied to clipboard
Update Fetch API
The new fetch API is just a copy of bs-fetch with a bit of re-arranging to separate out the inner modules (this aids tree shaking).
There are far better ways to do most of this in ReScript now; the API would benefit a lot from records-as-objects and polymorphic-variants-as-strings. Unfortunately, to a tree-shaking benefit from this the old Functor approach has to be removed.
As much as I'd like to update the API, there are over 1300 repositories depending on bs-fetch. Now that I know ReScript 10 will break their code, I want to start by making migration as seamless as possible for them.
So I'm tagging it as release 2.0 for now. If we have time for both the API update and a migration guide before ReScript 10 is released we can consider merging it in the 1.0 release.
Experiments here https://github.com/tinymce/rescript-webapi/compare/fetch-newapi (this will contain all changes until the core Fetch PR is merged)
Perhaps we can take some inspiration from the work @Kingdutch has done: https://github.com/Kingdutch/reason-fetch
It's gone in the direction of reason-promise, which is fair enough, but that's not suitable for Webapi. There are however many good ideas there that we can borrow.
Request from @ka-work in #33 - generalise Url.createObjectUrl to work for both Blob and File. Perhaps with some sort of blob_like type, similar to element_like.
This isn't specifically fetch related, but it's fairly close and I think the opportunity for a breaking change is a good time to do it.
I guess that make sense we would have to make some bindings for FileReader that I think takes both Files and Blobs for example. The createObjectUrl takes a media source though that isn't a subclass but that could be it's own function createObjectUrlFromMediaSource or something.