Fork me on GitHub
#fulcro
<
2019-06-17
>
Thomas Moerman14:06:07

Hi, a question about routers nested somewhere in the component tree: I had an issue with the router's props disappearing after performing a load with the component that hosts the router. My current solution is to modify the load like this:

(df/load-action env [:mx.study/by-id study-id] Study {
    :marker     :ui/loading-study
    :initialize {:report-router [:fulcro.client.routing.routers/by-id :report-router]}
    :without    #{:report-router}})

Thomas Moerman14:06:30

using :inititalize and :without in the load-action, is this the correct way to do it or is there a more idiomatic way to avoid/solve this issue?

Thomas Moerman14:06:44

So what this achieves, is that merging the result of the load-action doesn't mess up the router-instruction that sets the report id in the report-router that is nested a few levels under the Study component

kingcode14:06:35

Has anyone used fulcro with emacs/CIDER?

chrisblom09:06:36

I have, worked fine for me.

magra15:06:28

Worked fine with leiningen setup. With shadow-cljs and deps.edn for the server it tries to connect cljs to the running shadow-cljs clj repl from the file .nrepl.port. This does not work, but manually entering the same port number as the clj repl works here.

Thomas Moerman14:06:40

or slightly better than the above: use a :pre-merge on the component that hosts the router instead of the :initialize at load time

tony.kay15:06:03

Right, pre-merge is the more recent addn to the system that is meant to address these kinds of issues since it localizes the concern to the UI components and not the load.

tony.kay15:06:35

Another approach is to use a ui prefix on the router, or add a global query transform to the data fetch system that elides other keyword prefixes (e.g. :router/*) so that you can adopt a naming convention that will avoid having the thing be part of the graph query.

tony.kay15:06:50

depends on if you need occasional initialization or not…pre-merge allows you to do work (for example if the router itself wasn’t part of the tree yet), and the other approach avoids making the load accidentally include the router.

tony.kay15:06:29

I personally prefer making sure (via the :ui/ prefix) that the routers and such never end up in a load accidentally.

Thomas Moerman15:06:02

👍 I'll give the prefix :ui/ a try, that's the cleanest approach for sure.