Convert from ContT and Ajax FFI to Aff and Affjax
milesfrain opened this issue · 9 comments
I'm looking into fixing #118 and wondering if it would be good to replace some of the ajax FFI code with the Affjax library.
It's also tempting to write an Affjax replacement that uses fetch instead, although I assume the caniuse numbers for that feature (95%) aren't high enough for TryPurescript.
For reference, there's fetch-api, which uses node-fetch, but there could be an even lighter-weight and dependency-free wrapper for just browsers which uses built-in window.fetch.
As far as fetch goes, there are bindings in the purescript-web-fetch repository.
Excellent. I'm so glad I asked. I searched pursuit for fetch, but it doesn't look like web-fetch is tracked there yet.
Using fetch sounds good to me, especially if we can polyfill it for browsers which don't have it yet.
I'd also like to use Aff instead of ContT + Effect
I think if you're going to switch to Aff, what's wrong with using Affjax? I don't really see an advantage to using fetch, if it's also going to require a polyfill.
Oh yeah of course, that does make more sense. I guess I would usually default to fetch over affjax because in my experience it seems to work better in node (can't remember the details), but in this case we only need it to work in the browser, so that's irrelevant.
Affjax seems like the easiest path to success, so I'll go with that.
For reference, the Affjax changes exist in #192. Here are the relevant files for copy-pasting:
This was fixed in #208.