This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-06
Channels
- # announcements (1)
- # babashka (118)
- # beginners (108)
- # calva (20)
- # chlorine-clover (3)
- # clara (10)
- # clj-kondo (47)
- # cljsrn (10)
- # clojure (144)
- # clojure-australia (5)
- # clojure-czech (2)
- # clojure-dev (11)
- # clojure-europe (94)
- # clojure-france (4)
- # clojure-nl (5)
- # clojure-spec (3)
- # clojure-sweden (2)
- # clojure-uk (11)
- # clojuredesign-podcast (5)
- # clojurescript (56)
- # cloverage (1)
- # code-reviews (6)
- # conjure (1)
- # cursive (13)
- # datascript (1)
- # datomic (16)
- # defnpodcast (1)
- # emacs (1)
- # etaoin (1)
- # events (7)
- # fulcro (21)
- # graalvm (3)
- # helix (17)
- # jackdaw (3)
- # jobs-discuss (2)
- # lambdaisland (2)
- # london-clojurians (2)
- # meander (2)
- # mid-cities-meetup (2)
- # midje (1)
- # off-topic (1)
- # pathom (3)
- # pedestal (12)
- # reagent (7)
- # reitit (15)
- # reveal (12)
- # shadow-cljs (6)
- # sql (14)
- # test-check (3)
- # vim (13)
I am trying to implement a settings page with a separate router. Are there any examples in the wild? I noticed I can't just use a router, because when I do, the query won't be merged and thus the sub-routed component won't have any of its queried (and loaded) data available in props.
nesting routers is supported...not sure what you’re doing that is confusing you. You have to compose queries and initial state (though defrouter
does that for you for a router itself). I think the book itself shows such a nesting, doesn’t it?
It does indeed, and the helpful code is confusingly under "http://book.fulcrologic.com/#_setting_the_route_early" but yes, it works now 🙂
There is a http://book.fulcrologic.com/#_code_splitting but I have no idea how one'd combine that with a router
How does Fulcro support a basic index route? I tried :route-segment [""]
but that doesn’t seem to work with the back button
You can't give it an empty route segment. You have to put something there. You can then give app/fulcro-app
the key :client-did-mount
which takes a function. I have (fn [app] (hist5/restore-route! app ui/LandingPage {}))
if you want a “/” route you do that in your own function to translate between what you think of as a URL and the actual target…just like you would in a normal web serving env…`/` never names a resource. It’s a directory. So, if you were translating from a URL of “/” you’d have a fn in between URL and dr that would “alias” /
to mean something like ["index"]
core.cljs:159 ERROR [com.fulcrologic.fulcro.routing.dynamic-routing:636] - Could not find route targets for new-route []
I've been able to get mutations to alter behavior within a single component, but now I need set up an :onClick
mutation in some component X that changes some part of the state in another component Y. Anyone know where I can get more info on that? I'm probably going to start by rereading section 9 in the book.
From a client mutation you have the whole of app state. Start off with swap!->
[com.fulcrologic.fulcro.algorithms.normalized-state :refer [swap!->]]
, and do assoc-in
or call st->st* functions.That's what I suspected, but initial attempts weren't working. I will look into this, thank you!
Per http://book.fulcrologic.com/#_defining_remote_errors, I'm trying to handle server error responses, e.g. 401 responses. I have a fallback mutation on my transactions (e.g load!
) which I do see is being called, however the params :status-code
passed to this fallback mutation is 500, not 401 (which is the HTTP response code returned by the server). This is v3.4.2-1. What am I doing wrong? What do I need to do so that :status-code
matches the HTTP response code?
@tvaughan you might not be doing anything wrong…it could just be a mistake in the middleware copying the status code. I would not, in general, use status codes for error handling in Fulcro. Period. Assume a non-200 is a bug or network failure. Error handling makes a lot more sense to do as proper mutation return values.
this is different than what you might be used to from the REST world, but this is a different beast. It’s more like remote method invocation…an error means something went horribly wrong with the comm-layer (or a bug happened) such that the mutation was simply not able to even respond properly.
however, I do think the “raw” response is still in env
, so look deeper into what you got
> I do think the “raw” response is still in `env` A quick scan and I don't see it. Will continue to look. I don't follow that HTTP responses shouldn't be used to detect "errors." There could be a lot of things in front of a remote resolver or mutation that could intercept a request and send a response. Even in the RPC over HTTP world response codes aren't ignored. I'll see what sort of work arounds I can come up with. Thanks for the quick response!
core.cljs:159 WARN [com.fulcrologic.fulcro.ui-state-machines:215] - Attempt to get an ASM path [:com.fulcrologic.fulcro.ui-state-machines/local-storage :path-segment] for a state machine that is not in Fulcro state. ASM ID: :app.client/Router
#error {:message "", :data {}}
I found some related questions here, https://clojurians-log.clojureverse.org/fulcro/2020-02-14 - but I have dr/change-route!
in client-will-mount
and dr/initialize!
in my app start.