This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-24
Channels
- # announcements (3)
- # babashka (47)
- # beginners (40)
- # biff (21)
- # calva (12)
- # cider (2)
- # clj-kondo (31)
- # cljsrn (8)
- # clojure (14)
- # clojure-berlin (2)
- # clojure-conj (1)
- # clojure-dev (24)
- # clojure-europe (84)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (1)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurescript (34)
- # clr (3)
- # community-development (1)
- # cursive (14)
- # datalevin (8)
- # datomic (5)
- # defnpodcast (2)
- # dev-tooling (1)
- # etaoin (4)
- # events (3)
- # fulcro (26)
- # graphql (3)
- # honeysql (6)
- # hyperfiddle (45)
- # lsp (40)
- # malli (1)
- # missionary (1)
- # nbb (18)
- # podcasts-discuss (1)
- # reagent (8)
- # reitit (2)
- # releases (2)
- # ring-swagger (1)
- # scittle (78)
- # shadow-cljs (96)
- # vim (7)
- # xtdb (3)
Hi all,
I am using https://github.com/day8/re-frame-http-fx in my full stack clojure app (web and react native) using figwheel for the hot reloading.
re-frame-http-fx and so the underlying cljs-ajax work fine in react with the uri
as a relative path such as
{:http-xhrio {:uri "/pages/all"} ... }
However, when I try to use it in my react native frontend, all the exact same :http-xhrio
works as expected but I have to use an absolute path uri
instead such as:
{:http-xhrio {:uri ""} ... }
For web or mobile, I used fighweel with the embed ring server option on the default port 9500
How can I use the format "/pages/all" for mobile as well? I tried on ios with the Xcode simulator
You can find the http-xhrio for the web https://github.com/skydread1/flybot.sg/blob/master/client/web/src/flybot/client/web/core/db/event.cljs#L26 and the http-xhrio for mobile https://github.com/skydread1/flybot.sg/blob/master/client/mobile/src/flybot/client/mobile/core/db/event.cljs#L16
Thank youI’m not sure that would ever work, because in an app you aren’t “on a page” where a relative path would make sense, right? On the mobile web, you are on a web page that the browser can use to construct an absolute path from a relative path, but in an app you aren’t on anything.
What you could do is write a custom cofx that would automatically do it for you, so you’d have :localhost-http-xhrio { :uri "/pages/all" }
that would construct the url and pass it along to the normal http-xhrio
cofx.
I am confused, re-frame-http-xhrio
works from react native at all?
Since cljs-ajax
doesn’t use fetch
I thought this wasn’t possible
https://github.com/day8/re-frame-http-fx/issues/23
It’s really simple to write your own fx, it’s only about 10 LOC: https://increasinglyfunctional.com/2019/06/25/http-fx-for-re-frame-on-react-native.html
@U0E1JV8GK Thank you for the clarification regarding the difference between web and mobile URIs shapes.
I ended up using the google closure compiler option :https://clojurescript.org/reference/compiler-options#closure-defines which I can easily override with https://figwheel.org/docs/compile_config.html.
Then my uri is just (str BASE-URI /pages/all)
with BASE-URI being defines as (goog-define BASE-URI "")
So it works for web and mobile but also dev and prod as well.