This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-14
Channels
- # aleph (2)
- # announcements (11)
- # aws (4)
- # babashka (42)
- # babashka-sci-dev (81)
- # beginners (90)
- # biff (2)
- # calva (40)
- # cider (16)
- # clj-kondo (26)
- # clj-on-windows (1)
- # cljdoc (4)
- # cljfx (1)
- # cljsrn (2)
- # clojure (92)
- # clojure-austin (2)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-uk (3)
- # clojured (3)
- # clojurescript (19)
- # community-development (3)
- # conjure (1)
- # cursive (4)
- # datalevin (3)
- # datomic (5)
- # emacs (13)
- # events (1)
- # fulcro (26)
- # graphql (1)
- # hugsql (15)
- # introduce-yourself (5)
- # leiningen (1)
- # lsp (29)
- # minecraft (19)
- # music (1)
- # off-topic (36)
- # pathom (12)
- # podcasts (2)
- # portal (8)
- # re-frame (12)
- # reagent (11)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # spacemacs (2)
- # vim (12)
- # windows (3)
- # xtdb (43)
Hi @tony.kay, do you have any hints what I am doing wrong, when will-enter gets called thrice per one route-to? I am just now realising that this is not normal ;-)
check out the warning at the bottom of this section: https://book.fulcrologic.com/#_routing_targets
will-enter can be called multiple times as part of the route resolution algorithm and MUST NOT side-effect. Any I/O must be done in the lambda passed to route-deferred, which must then trigger the dr/target-ready mutation to indicate that the route is ready. You can use plain transact! to start a mutation within route-deferred, and the mutation can use target-ready! to send the signal.
Thank you @U016TR1B18E! I just misread a paragraph of the book today, got confused and thought I did something stupid the last two years. Thanks!
yeah its quite subtle, glad it was helpful!
The two are not compatible. Mutations are async by default, and you’d need to use route-deferred.
Otherwise, write a mutation that does the operation you want before routing, and have that mutation call the routing function. Then you’ll be sure the state has changed before the route appears.
There are all sorts of ways of structuring this…for example, you could invent your own pre-routing handler with the following scheme:
1. Add an option to the target like :custom/pre-routing (fn [app])
or whatever signature suits you
2. Write a wrapper function for routing that takes the target..e.g. (custom/route-to! this Target)
3. In this custom function, you can pull the pre-routing handler, and invoke it
(let [{:custom/keys [pre-routing]} (comp/component/options target)]
(when pre-routing (pre-routing ...))
(dr/change-route ...))
See RAD’s routing helpers for other ideas as well. https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/routing.cljc#L26I used componentDidMount so far, but that bites me when the old route and the new route only differ in the id part of [:person/id id].
I do not want to switch this use case to route deferred because route-immediate gives me a much smoother transition from the old route to the new (and when I do use route deferred in case the data is not yet loaded).
Hi there. I'm having some problem issuing a df/load-field!
with :params
, that is the params are not retrievable via (-> env :ast :params :foo)
. I've asked this question in #pathom and was told it's because Pathom is expecting the params to be somewhere else. For context, here's the thread: https://clojurians.slack.com/archives/C87NB2CFN/p1649936416099369
For now the solution seems to be either writing a plugin to propagate the params downward, or to modify the query itself before sending it. I'm hoping someone could point me in the right direction to how to achieve these. Thank you 🙂
See https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/pathom.clj#L110
that’s a plugin that will take load params and move them into :query-params
in pathom env for Pathom 2
This is the same trick for 3: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/pathom3.clj#L122
@tony.kay, is there a reason for this conceptual difference between params at "entity level", vs "per attribute"? (glad to find the Pathom3 solution!)
This has come up multiple times lately. Perhaps it would be helpful to document it in the dev guide and/or move the plugging from RAD into Fulcro proper?
Parameters in the elements of the query would require constant use of dynamic queries in Fulcro, which I’ve always found to be a pain. You can do that, though, and EQL already supports carrying them in the right place and pulling them out at the resolver layer. IMO, though, namespaced parameters on the top-level query are sufficient for the vast majority of cases, are simpler to use, and can easily be pulled out into the pathom env. So, I use them way more…in fact, pretty much exclusively. I could (and have) gone on at length about the design of the loading infra in Fulcro…see videos/book/etc.