This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-14
Channels
- # adventofcode (29)
- # aws (3)
- # babashka (25)
- # beginners (13)
- # calva (4)
- # cherry (7)
- # cider (26)
- # clj-kondo (9)
- # clojure (88)
- # clojure-europe (21)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (11)
- # clojuredesign-podcast (2)
- # clojurescript (4)
- # cursive (10)
- # datalevin (1)
- # emacs (50)
- # gratitude (1)
- # honeysql (12)
- # hyperfiddle (19)
- # jobs-discuss (28)
- # kaocha (3)
- # lsp (53)
- # malli (4)
- # meander (3)
- # off-topic (48)
- # re-frame (11)
- # releases (2)
- # ring-swagger (2)
- # shadow-cljs (50)
- # squint (26)
- # tools-build (3)
- # tools-deps (8)
- # xtdb (4)
- # yamlscript (1)
What are people’s preferred method for implementing retries when an XHR from re-frame-http-fx times out?
One can naively create an :on-failure
event that checks (= :timeout (:failure response))
, but I dont like this since it involves manually reconstructing the event, and it seems to abstract this into a “composable” or “generic” event handler.
I rarely use interceptors, so I don’t have a good intuition for them, but they seem to solve the issue of reconstructing the original http-fx event that failed. So I want to consider trying them out. Has anyone here tried using interceptors for this? and if so, do you have a simple example?
> manually reconstructing the event Why? You already have the whole event vector there, just pass it along, maybe with a retry counter.
When the :on-failure
event is fired, I only get the event vector of the failure handler, not the event that makes the AJAX call
e.g. suppose I (rf/dispatch [:api/get-things {:id 123 :on-success [:handle-success] :on-failure [:handle-failure]])
You have the original event vector where you create the XHR effect.
You can pass that vector to the :on-failure
event vector. Event in event.
you’re absolutely right… the event vector in my above example is already in the :api/get-things
handler…