This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-26
Channels
- # beginners (145)
- # boot (19)
- # calva (61)
- # cider (33)
- # cljs-dev (15)
- # cljsrn (16)
- # clojure (35)
- # clojure-dev (39)
- # clojure-russia (2)
- # clojure-spec (10)
- # clojure-uk (7)
- # clojurescript (5)
- # cursive (14)
- # data-science (1)
- # datomic (3)
- # figwheel-main (9)
- # fulcro (46)
- # jobs (4)
- # off-topic (8)
- # quil (6)
- # re-frame (5)
- # shadow-cljs (70)
- # spacemacs (3)
- # speculative (2)
- # tools-deps (2)
nothing has disappeared, it’s just some of the template stuff you might see doesn’t match up.
@tony.kay Good evening 🙂 I was reading through the routing section of the book / examples today and I don’t quite understand how idents for screens should be picked. The first part of the ident is the page (which afaik is so that we can do a union query on it), but the second part of the ident seems arbitrary. What is its role?
@hmaurer that confused me for a while too, but it’s simpler than i first thought
you’re right the first part is the page, because of union queries, and the second part is arbitrary
the can second part can be a constant when you’re looking at a fixed screen like [:dashboard :tab]
or in the same router you can swap in an ident for a specific record [:person/by-id 123]
the first part has to be distinct per route, and the second can be whatever, including something the query engine can use to fulfill your query results (like an ident of some data you loaded from the server)
@currentoor thanks for the reply! so if the second part is a constant, then it doesn’t matter at all what it is, right? And here you gave me an example where the ident is a record; how would you represent a route to a screen with a query that has a few dynamic parameters depending on route parameters? Would that be a constant as well, and then you would pull the parameters when loading the data?
i can give you an example
That would be great, thanks 🙂 And while I am at it, where do you put data loading for a route? I was thinking of inserting a call to df/load
in https://github.com/fulcro-legacy/fulcro-template/blob/develop/src/main/fulcro_template/ui/html5_routing.cljc#L94 (based on the match)
so i know it’s possible but i don’t bother putting the data needed for a load in a route
that is one way of doing it but certainly not the only way
like that
you can open that in github, it’ll look better there
slack tried to inline it
but i first navigate to list view, which loads a list of tax-ids and their names (aka titles)
then when i click on a listen element i call df/load
both loads can happen in componentDidMount, or in a route change handler
I see; reading through your code now; it looks like it also has loading indicators, which is another thing I’ve been trying to figure out 🙂
@currentoor componentDidMount seems like a good place; it gives you access to props to parametarise the query as well
i find componentDidMount is fine for getting it working quickly, but probably better to do it from a route change event handler type thing
in this project i’m using state machines all over the place and so i call load in state machine event handlers (along with route changes and whatnot)
@currentoor https://gist.github.com/hmaurer/9ed3992266288382435f88095d743257#file-mixed-router-cljs-L102 ; when I tried to implement loading indicator I had a flickering issue where the indicator would initially not render.
@currentoor did you encounter a flickering issue at first when you tried to implement these?
so find out why the flicker, are your props nil?
what’s turning them into nils?
is the load? turn that off and use stubbed data in app state
@currentoor well I think what was going on is that my UI was rendering before I triggered df/load
, and so that that point there was no loading marker
ok then show a loader whenever there is a load marker OR props are nil
@currentoor Alright, thanks, will try that. Last question: when you do a df/load
for tax details, do you set the :marker
option?
yes, the marker is set to :actor/detail
and that’s what i’m checking for in the render
no worries
> but probably better to do it from a route change event handler type thing isn’t that what I was suggesting initially? Putting it in the pushy callback? or am I misunderstanding it?
depends on if you’re using URL routing which is different than fulcro routers
the two can work together, in my project i’m not using URL routing
@hmaurer another downside to componentDidMount
is if you’re load is broken then it can cause your component to re-mount, which triggers yet another broken load and goes on in an infinite loop
if you do your loads in an event handler (state machine, onClick, client mutation, etc) then you can be sure it only happens that one time
are there any similar hooks to afterRender
built into Fulcro? I’m trying to use this, https://github.com/PEZ/clerk#after-render