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

Require fetch object to be passed in #25

Open
mlms13 opened this issue Oct 11, 2022 · 1 comment
Open

Require fetch object to be passed in #25

mlms13 opened this issue Oct 11, 2022 · 1 comment

Comments

@mlms13
Copy link
Member

mlms13 commented Oct 11, 2022

Currently, we're assuming (really, bs-fetch is assuming) that the fetch global exists. This is true for browsers, but for other environments like Node or React Native, this requires a polyfill like isomorphic-fetch or cross-fetch. Importing one of those libraries purely for the side-effect of attaching junk to the global object is really gross (and worse, it's easy to forget to do, which could cause things to break at runtime).

I'm definitely open to ideas, but it seems like the safest thing to do would be to expect ReludeFetch to be constructed with a Fetch object (module?) that provides the actual fetch implementation. In a more perfect world, maybe we'd have a trifunctor IO like ZIO where the Fetch interface could just be part of the environment.

@andywhite37
Copy link
Member

I'm totally fine with whatever you want to do here. I agree that bs-fetch and hence relude-fetch were kind of built with the assumption that fetch just exists in the global env, which is not great, but might also be something to just embrace, and require people to polyfill it however they want to, just like any other JS global inconsistency.

It would be cool to have a non-global/polyfill-based layer of indirection though - that would make testing things easier.

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

No branches or pull requests

2 participants