This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-27
Channels
- # announcements (7)
- # aws (1)
- # beginners (42)
- # calva (65)
- # clj-kondo (5)
- # cljs-dev (11)
- # clojure (69)
- # clojure-australia (7)
- # clojure-dev (4)
- # clojure-europe (9)
- # clojure-gamedev (2)
- # clojurescript (2)
- # conjure (4)
- # cursive (1)
- # data-science (1)
- # datomic (8)
- # events (1)
- # fulcro (35)
- # graalvm-mobile (40)
- # introduce-yourself (1)
- # lsp (26)
- # malli (14)
- # mathematics (2)
- # missionary (5)
- # nextjournal (4)
- # off-topic (4)
- # polylith (10)
- # shadow-cljs (5)
- # test-doc-blocks (1)
- # tools-build (24)
- # tools-deps (1)
- # xtdb (12)
How can I tell my dynamic router that some string should be interpreted as a uuid?
You don’t. That is not a router’s responsibility, it’s yours 😄 You get the string, and you convert it. Simple enough for you to make helpers and such to configure such a thing. For example, you can put your own nsed keywords into the component’s option map, and get those with component-options. So, you could declare what types the parameters are, and then create a helper function that takes the class and route params and returns a map with things coerced. I’m not necessarily opposed to such abilities in the router, but a lot of the bits of Fulcro are intentionally minimal and aimed at getting the minimal thing working. You’re in a language where your own derivation is just a function or macro away.
I’m still learning fulcro, especially the vocabulary, but my issue seems to be that my query through a router isn’t giving me back the data from my database because it can’t follow an ident where string/uuid are mismatched.
When I use the db explorer to go through the database ident-by-ident, I get to this router’s “current-route” property, which needs to be something like [:user/id #uuid "some-uuid-string"]
but the uuid reader tag is missing so nothing is found. That string (as a uuid) does correspond to a valid ident
correct. Routers always have strings (and force parameters to strings) because those are universally available for resuming a route (paths are strings from browser). So, you will get strings for those params (embedded in the URL) in your will-enter
I don’t understand where I can convert it so that the query finds the right data
The point is that even if you originally used a UUID to route there, if someone were resuming the page through HTML5 routing, then you’d get a string. So, DR forces them to strings to make sure you hand;e that case.
it’s your code…I don’t know where you’re passing it, but I know Fulcro isn’t magically running a query for you, unless you’re using RAD, but that’s a different story.
I was calling comp/get-query
on the router to get the query and see where things seemed to be going wrong
Yes, I have a df/load in a callback on will-enter
That sounds right. I ended up refactoring this code to use mutation joins to grab the data I needed, so I’m not 100% sure.
I’m going to work on changing it back to using a router and hopefully I can figure this out
Thanks for the help! 😄
I’m loving Fulcro, btw, thanks for that too
Sure. So, this is a very old video I made back in the Untangled days (the old version of Fulcro based on Om Next). The basic concepts still apply and may be useful to you. Just understand the specific code references are outdated. I really need to remake it with pretty graphics (or at least readable 😜 ). The book covers this all, but sometimes its helpful to see something like this: https://youtu.be/mT4jJHf929Q
I got the code setup using the router, and I’m 99% sure I was not converting to a uuid in route-deferred. 😄
@UJL94RYSW have you seen https://fulcro-community.github.io/guides/tutorial-advanced-minimalist-fulcro/ ?
Yes! That was super helpful for me getting started (the fulcrobook can be intimidating at first)
The example in https://fulcro-community.github.io/guides/tutorial-advanced-minimalist-fulcro/#_loading_data_when_a_component_is_routed_to_for_the_first_time shows how to parse a route parameter from string into an int. It is the ± same for uuids and anything else. I guess that was not really clear from the text?
I think I just forgot to do the translation
2.a under https://fulcro-community.github.io/guides/tutorial-advanced-minimalist-fulcro/#_the_bare_essentials_of_fulcro_routing reads > ... route parameters (which are always strings) ...
Ah, ok. I am always looking for ways to make things clearer and decrease the chance for an error.
At this point, I think what would’ve been most helpful, post-conceptual understanding, would be a video/demo of how to go about building something fairly trivial. I feel like what I struggled with most was understanding how the various concepts and pieces fit together into the context of building something more realistic.
After building up some more confidence, I might try creating something like that myself 😅
Ok. I suppose fulcro-exercises helped you to get familiar with the basic stuff but you need the next step of st. more realistic and complete, right?
Oh dang, I need to be reading more resources, I hadn’t seen that before!
But overall, yes. In isolation, everything made sense fairly quickly, but connecting those isolated pieces was confusing for a bit.