This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-08
Channels
- # announcements (2)
- # asami (2)
- # babashka (7)
- # beginners (59)
- # cider (12)
- # cljdoc (1)
- # cljs-dev (18)
- # clojure (23)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojured (16)
- # clojurescript (22)
- # core-typed (8)
- # cursive (3)
- # datomic (24)
- # events (2)
- # fulcro (4)
- # gratitude (1)
- # helix (13)
- # hoplon (18)
- # integrant (2)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # joyride (5)
- # minecraft (1)
- # off-topic (76)
- # pathom (18)
- # podcasts-discuss (8)
- # polylith (11)
- # remote-jobs (4)
- # rewrite-clj (22)
- # sci (4)
- # shadow-cljs (152)
- # sql (4)
- # tools-build (26)
- # tools-deps (34)
How do you fellow helixers fetch on the browser ? Do you use js/fetch or its wrapper https://github.com/lambdaisland/fetch or something else.
@U09LZR36F Do you use a library for promises ?
No I remember: lambdaisland pulls kitchen-async which pulls core-async which is on hold for https://www.juxt.pro/radar 2021
promesa looks well written/behaved wrapper. No dependencies, documentation.
Yeah, I trust most of the funcool libs, they are battle tested in https://github.com/penpot/penpot
https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L106 this p/try block from kitchen-async has no equivalent on promesa, so i changed the p/let inside the p/try to . That proves @U09LZR36F point, native .then and .catch are more than enough for operations. I'm using p/promise constructor on decode-body in case the implementation (its a multi-method) does not give a promise back.
the fetch operation https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L105 is not being guarded by the p/try block, which opens the door to something wrong with it. the p/let block captures a response, the fetch api says it does not reject on 404 errors. it only rejects on network errors. the next promise operation is https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L113 decode-body. I wonder how the https://github.com/athos/kitchen-async/blob/master/src/kitchen_async/promise.cljc#L126 p/try from kitchen-async is able to intercept rejected promises on the code. I know the code is there but my brain is not lispy enough to understand how. Is it really feasible ? because the native promise handling is dependent on chainning, and I think promises are different from exceptions semantically.
despite the kitchen-async dependency pulling core.async, I liked lambdaisland.fetch. It pairs with muuntanja at server side, which responds to content-type. It defaults to asking for transit content, and has multi-methods to decode body based on the content-type.
I think I've found an issue in https://github.com/lambdaisland/fetch/issues/19