This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-22
Channels
- # beginners (55)
- # cider (22)
- # cljs-dev (123)
- # cljsrn (75)
- # clojars (1)
- # clojure (92)
- # clojure-europe (2)
- # clojure-italy (16)
- # clojure-nl (6)
- # clojure-spec (17)
- # clojure-uk (77)
- # clojured (2)
- # clojurescript (39)
- # core-async (8)
- # cursive (4)
- # data-science (1)
- # datomic (22)
- # duct (4)
- # editors (21)
- # emacs (10)
- # events (4)
- # fulcro (116)
- # graphql (8)
- # immutant (3)
- # jackdaw (1)
- # juxt (3)
- # kaocha (4)
- # luminus (1)
- # mount (1)
- # nrepl (32)
- # off-topic (34)
- # other-languages (5)
- # pedestal (32)
- # reagent (1)
- # ring (6)
- # ring-swagger (7)
- # shadow-cljs (5)
- # spacemacs (3)
- # specter (1)
- # sql (1)
- # vim (21)
Is there any support for a URL such as user/id/products
with the dynamic routing?
@pvillegas12 of course…do the docs not make it clear?
trying to get it to work right now
using #(dr/change-route-relative this UserDetails ["products"])
but in the will-enter
I’m not receiving the user id
tried doing (dr/change-route this ["user" id "products"])
too
But it chops off products
in this case for some reason (loooking at the fulcro db for routing)
Fulcro 2.8.3 on Clojars, and Incubator 0.0.29. The Fulcro fix is a long-overdue fix to fulcro logging. The incubator fix adds debug logging (which requires 2.8.3 of Fulcro) to state machines so you can see how they are working. Incubator also has deferred routing fixes for dynamic routing. See the docs, as the API had to include a new method to accomplish it properly.
@pvillegas12 what is your prefix defined as for the route target?
:route-segment (fn [] ["user" :user-id])
right
correct
the route params are the ones I’m not receiving
should I upgrade to the latest fulcro?
You may have discovered another bug….darn-it, I just finished fixing the last one you found 😉
should I be doing the dr/change-route-relative
or dr/change-route
?
both should work right?
either ["user" id "products"]
or simply ["products"]
with the right prefix class
the latter should work if you pass the router whose targets include one that accepts “products”, yes
The former would have to be sent to the router that targets the prefix target accepting “user”
If you upgrade to the latest versions, you’ll be able to see a LOT more info with debug logging in console
I’ll do that right now
After updating getting more debugging info, looks like it does the RootRouter
transition but
Attempt to get an ASM path [:fulcro.incubator.ui-state-machines/local-storage :pending-path-segment] for a state machine that is not in Fulcro state. ASM ID: :dataico.ui.user.details/UserRouter
it complains on the UserRouter
I’m done for tonight…basically when you route it calls begin on the state machine it matches. Perhaps for some reason it isn’t ok with the id-based target
thanks for looking into it 🙂
I may have time to look at it more tomorrow. The source isn’t that large if you wanted to clone incubator and do deps :local/root and debug it further
in https://wilkerlucio.github.io/pathom/#_parameters queries like:
[(::instruments {:sort :instrument/brand})]
have to be quoted in fulcro right?
(defsc MyComp [this props]
{:query ['(::instruments {:sort :instrument/brand})]}
)
also is (-> env :ast :params) correct? I have to do
(-> env :ast :children first :params)
(my query shows as a :type :join, so I may be doing something wrong)ah - probably because I have a {:all-instruments (prim/getQuery MyComp)}
in my root - not sure how to avoid that
because if I remove :all-instruments
in my root query - how do I: :started-callback (fn [dashboard] (df/load dashboard :all-instruments MyComp))
?
@nha if you component has an ident, you can use the ident instead of a keyword to load a specific instance.
but if you intend to load “many” like your q implies, then why wouldn’t you want that join?
Right that’s possible too - not very confident in the way of writing queries yet. the Pathom docs did help a lot though. I wish there was a way to “play” in the fulcro docs like in the pathom ones - particularly around the queries/idents/normalisation as I feel like I have to re-learn it every time.
The query tab has autocomplete, etc. (if you load indexes with the button next to run)
@tony.kay got the routing working finally, traced down the bug in my code 🙂
I have the following routing structure
CompanyDetails [:company/by-id :company-id]
| \
UserDashboard InvoiceDashboard
How can I pass the company information to both of these sub-routes?UserDashboard
and InvoiceDashboard
are defined in the CompanyRouter
, not the RootRouter
as CompanyDetails
, so I don’t have access to the router param for the :company-id
@pvillegas12 you mean you want to use the current route to figure out the new one?
1 - Use relative routing to avoid needing to know it 2 - Read the current route and pull it out of the path segments 3 - Remember the value in a well-known location in app state and use abs change route (e.g. when you originally set the route, remember it)
What I would like is to pass company
as props to my UserDashboard
and InvoiceDashboard
basically, CompanyDetails
makes the query to the server, and switches UI for both dashboards already having the data
I’m having props being empty in my defsc-route-target
declarations of course, because my query lives in the parent
also should be easy to proxy computed through…so if you pass computed to the router, it passes it to the target
I’ll try the computed approach
@pvillegas12 0.0.30-SNAPSHOT on clojars
@pvillegas12 Incubator 0.0.30 is on clojars, and includes computed props proxying through the router.
Just to clarify, this means something like
(ui-router (prim/computed router {:my-prop my-prop}))`
and then
(defsc-route-target UserDashboard [this _ {:keys [my-prop]}]
...
)
hmm, not getting the computed, is it necessary to use dr/route-deferred
?
(defsc-route-target CompanyDetails
[this {:keys [company/pos-systems company-router] :as props}]
{:ident [:company/by-id :db/id]
:query [:db/id :company/name {:company-router (prim/get-query CompanyRouter)}]
(ui-company-router (prim/computed company-router {:X :a})))
Is there something wrong with this setup? @tony.kayperhaps cursive is not loading the dependency properly
trying again
what is the equivalent of nuking all deps for shadow cljs?
but in answer to your question: Remove .shadow-cljs (project root) and the cljs-runtime directories (build paths)
@tony.kay maybe I’m hitting this clause https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/main/fulcro/incubator/dynamic_routing.cljc#L493
Should that be (prim/computed ~'current-route (prim/get-computed ~'this))
?
Your ws has User
being hit in the top router, not going through the nesting I have
The point is I pass computed to a router, and it proxies it through to whatever target it is routed to…nesting does not matter….wait: you’re not trying to have it automatically go through all levels are you?
hahaha, that’s what I think 😛
I’m passing the computed on the CompanyRouter
which targets a component
so it is direct (like your User
example)
There is one difference
If you need to go through to the next level, then it has to be passed as computed again to the next router
My CompanyDetails
target is deferring
the ProductDashboard
is doing a dr/route-immediate
that is basically the difference
you probably need to force a refresh of the UI higher in the tree on route resolution
how can I do that?
basically, teh example has
https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/workspaces/fulcro/incubator/routing_ws.cljs#L125
I am doing that on a defsc-route-target
component with a dr/route-deferred
I don’t have the time to play with it anymore today, sorry…the deffered is suspicious though
What’s the way to load the incubator locally to tweak it’s behavior?
yeah, that’s it thanks!