This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-20
Channels
- # announcements (7)
- # babashka (16)
- # beginners (58)
- # boot (12)
- # calva (3)
- # cider (11)
- # clj-kondo (9)
- # cljs-dev (8)
- # clojure (82)
- # clojure-europe (9)
- # clojure-italy (11)
- # clojure-losangeles (1)
- # clojure-nl (8)
- # clojure-uk (8)
- # clojurescript (5)
- # css (2)
- # cursive (5)
- # datomic (20)
- # docker (2)
- # emacs (4)
- # figwheel-main (16)
- # fulcro (53)
- # graalvm (17)
- # jackdaw (2)
- # jobs (4)
- # kaocha (6)
- # lambdaisland (2)
- # luminus (2)
- # meander (1)
- # off-topic (146)
- # re-frame (4)
- # releases (1)
- # rum (12)
- # sci (71)
- # shadow-cljs (26)
- # test-check (22)
- # vim (1)
- # xtdb (9)
I have a component with :route-segment ["tenant" :tenant-id]
but the router won't accept it. I get "Spec failed. :tenant-id should satisfy string?". I have no clue why this happens. This is a valid route segment, and I use the same thing in other forms.
@U2APCNHCN route segments are FORCED to strings (because they must be supportable from URLs which are strings). You’re probably passing a non-string to one of the functions that does routing, and it is warning you that you’ve used non-string data in routes.
The routing works fine when using Fulcro's and Fulcro RAD's routing functions, but as soon as I want to access a parametrized page by URL, as in typing it in the address bar and pressing return, it falls apart
take a look at other thread @U2APCNHCN
are you trying to use (dr/change-route! ["tenant" "id here"])
? can you post the stack trace?
No, I am not. In fact it even happens when I am not using dr/change-route!
at all. I am using dr/deferred-route!
, but it clearly doesn't even reach that statement because the log/info I've put in front never gets executed. Here's the stack trace of the other form that also doesn't work for the same reason:
Hmm actually the same happens for every form when I call the route directly as URL, instead of routing to it using dynamic-router
Yes, apparently. Despite me doing it exactly as described in the book. And it works when routing from inside the app. The problem is accessing the route by URL (as in having the browser make the request "from zero")
so it looks like your call to push-route!
which is coming from html5 routing plugin ends up with a keyword at that location instead of a string.
Ah, route history restores stuff form the URL params, and your URL has the keyword embedded in it for some reason
so when you re-use that URL, it transit decodes the params in the URL and sends them, but they have invalid data in them for whatever reason
Your problem is NOT on “load from scratch”, its somewhere where you’re setting paramters that get saved in the URL (all controls on the form/report)
This is what my fix-route
looks like:
(m/defmutation fix-route
"Mutation. Called after auth startup. Looks at the session. If the user is not logged in,
it triggers authentication"
[_]
(action [{:keys [app]}]
(hist5/restore-route! app ui/Root {})
))
Maybe the problem is there?So, clearly I should have better error messages in the routing code, but if it is giving you errors related to a different route then: 1. Your “default route” might be the tenant one, which will fail because no params are possible on init 2. The URL you’ve given has no legal match, so it is doing something unexpected…
I have more, same goes for :route-segment ["vendor" :vendor/id]
, it works fine with (rroute/route-to! this VendorDetailView {:vendor/id whatever-the-id-is})
but http://localhost:3000/vendor/whatever-the-id-is will fail, even though that is what ends up being in the address bar after the route-to!.
Ah, I tried it in Firefox and can actually see it change the URL to one where it includes the keyword when calling the URL with the browser.
strange…I’d have to go back through the code. Not sure what’s going wrong there. It is working fine in my apps, and in the demo.
Hmm. I will also look through mine as well. Might be something with how I redirect after checking if the user is logged in. That turned out to be a massive mess to do with all the async that is going on
yeah, that’s why I use a UISM for login..and when you mix in html5 history support things get interesting if you don’t keep it really clean
so where is your extra async? Or you mean you have not taken the time to understand what is there?
Well, first I have to make sure my program waits until the UISM has figured out if the user is logged in or not, and then it has to check if the user is allowed to see the requested page depending on the session map the UISM fetched, and then do a redirect if not; but also, if and only if the user is on the landing page it has to redirect to whatever is the actual landing page for the user role.
right, so it sounds like perhaps you should have a flag that prevents all rendering (on root) until all that mess is figured out, and probably does not install history event listeners until you’ve got that as well.
Okay I created another new form with a route segment with a keyword and get the same error as well...
My route segments are either ["person-list"]
or ["person" :person/id]
in the first case my :ident
is a function (fn [] [:component/id :person-list])
and in the latter it is :person/id
.
I have a top level property in my app db that I want to load a collection of idents into, but I want the load to but cumulative (issuing multiple loads should append data and not clear the vector) - when I issue a df/load!
that targets that top level property the data from the load overwrites the collection that is there - using target append-to does not work either.
Is this a supported use case or will I have to use a mutation and handle the merge logic myself?
what do you mean “`append-to` does not work either”? Ah, append-to might to for to-one only. I would consider that an oversight…I’ve never used it for that. I’d accept a PR for a check in append-to that would do collections I guess. Your option right now is just to make it a post-mutation of your own. Ultimately, that’s all data targeting is.
yep - it's a collection of idents - I will try out the post mutation option for now and may look into updating the data targeting to support that.
The fulcro docs for form state have this example input:
(dom/input {:value (or name "")
:onBlur #(comp/transact! this [(fs/mark-complete! {:entity-ident [:person/id id]
:field :person/name})
:root/person])
what's the :root/person
doing in the transaction?i think @danvingo correctly described its function below. as additional info, the book appears to call it a "follow-on read" if i understand correctly. http://book.fulcrologic.com/#_historical_note_on_older_approaches http://book.fulcrologic.com/#_combining_routing_with_data_management