clojurescript

opqdonut 2024-11-29T08:29:17.554999Z

is there any reason to use cljs-ajax ie. goog.net.XhrIO rather than fetch (either directly via js interop or via a cljs wrapper)?

opqdonut 2024-11-29T08:30:57.916279Z

heh, people were wondering about XhrIO already in 2018: https://github.com/JulianBirch/cljs-ajax/issues/204

thheller 2024-11-29T08:31:47.904189Z

I'd only use fetch these days, via plain interop. no wrappers.

👍 2
opqdonut 2024-11-29T08:32:31.976459Z

yeah that's what I've done previously. I'm looking at a project now that's using re-frame-http-fx, which uses cljs-ajax and I started wondering...

thheller 2024-11-29T08:35:11.473469Z

well that is different. fx are still a useful abstraction. doesn't warrant bringing in cljs-ajax though. dunno if a library exists that just uses fetch instead?

p-himik 2024-11-29T08:37:52.068949Z

Yes, there's one, by one of the guys from Day8 if I'm not mistaken.

opqdonut 2024-11-29T08:38:10.732589Z

yeah I found https://github.com/superstructor/re-frame-fetch-fx

opqdonut 2024-11-29T08:38:39.080669Z

I'm probably just going to write my own effect using fetch, since I want to bundle in some app-specific behaviour (like 401 handling etc)

Roman Liutikov 2024-11-29T10:09:27.722579Z

one important difference is that unlike Fetch, XHR supports progress tracking https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/progress_event

p-himik 2024-11-29T10:18:04.795059Z

It's possible with fetch as well, but it's definitely more cumbersome.