Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Fetch API #30

Open
TheSpyder opened this issue Sep 23, 2021 · 4 comments
Open

Update Fetch API #30

TheSpyder opened this issue Sep 23, 2021 · 4 comments
Projects

Comments

@TheSpyder
Copy link
Owner

TheSpyder commented Sep 23, 2021

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.

@TheSpyder
Copy link
Owner Author

TheSpyder commented Sep 23, 2021

Experiments here https://github.com/tinymce/rescript-webapi/compare/fetch-newapi (this will contain all changes until the core Fetch PR is merged)

@TheSpyder
Copy link
Owner Author

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.

@TheSpyder
Copy link
Owner Author

TheSpyder commented Oct 29, 2021

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.

@spocke
Copy link
Collaborator

spocke commented Oct 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants