fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
zilti 2020-10-06T01:05:53.147700Z

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.

zilti 2020-10-06T01:06:31.148300Z

There is a http://book.fulcrologic.com/#_code_splitting but I have no idea how one'd combine that with a router

exit2 2020-10-06T01:24:16.149100Z

How does Fulcro support a basic index route? I tried :route-segment [""] but that doesn’t seem to work with the back button

exit2 2020-10-06T01:24:37.149400Z

core.cljs:159 ERROR [com.fulcrologic.fulcro.routing.dynamic-routing:636] - Could not find route targets for new-route []

zilti 2020-10-06T01:50:16.151100Z

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 {}))

tony.kay 2020-10-06T01:53:03.151300Z

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"]

1👍
tony.kay 2020-10-06T01:54:49.151500Z

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?

zilti 2020-10-06T02:05:20.151700Z

It does indeed, and the helpful code is confusingly under "http://book.fulcrologic.com/#_setting_the_route_early" but yes, it works now 🙂

aratare 2020-10-06T03:33:14.151900Z

It's working now. Thanks.

Mr. Savy 2020-10-06T05:00:44.155400Z

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.

Mr. Savy 2020-10-07T03:30:19.172100Z

That's what I suspected, but initial attempts weren't working. I will look into this, thank you!

cjmurphy 2020-10-06T06:31:25.155500Z

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.

tvaughan 2020-10-06T13:38:28.159300Z

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?

tony.kay 2020-10-06T13:42:12.160600Z

@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.

tony.kay 2020-10-06T13:43:35.162100Z

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.

tony.kay 2020-10-06T13:45:18.162900Z

however, I do think the “raw” response is still in env, so look deeper into what you got

tvaughan 2020-10-06T13:52:17.165900Z

> 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!

tvaughan 2020-10-06T14:38:41.166Z

:status-text is Unauthorized. Using this seems to work

exit2 2020-10-06T19:10:42.169700Z

Any advice on getting rid of this warning?

exit2 2020-10-06T19:10:43.170Z

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 {}}

exit2 2020-10-06T19:12:22.171600Z

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.