Fork me on GitHub
#fulcro
<
2020-08-11
>
AJ Snow01:08:53

ok turns out I was right the whole time, I am incompetent. you can't be wrong if you predicted you were being dumb in the first place!

AJ Snow01:08:13

now I'm just confused. if you have some component why would it matter to defmutation if you name the key in the parameter :root/keys vs :ui/keys in the component design? I thought they were just naming conventions, but it looks like the key names have external effects?

ozzloy01:08:17

@diarmad i think it's talking about how you can do (ns a.b (:require [com.fulcrologic.fulcro.application :as app])) and then you can use app later in your code instead of the full com.fulcrologic.fulcro.application.

ozzloy01:08:40

@diarmad maybe it's talking about line 30 :com.fulcrologic.rad.database-adapters.sql/table or possibly ao/identity? or ao/schema. it would be nice if the word "These" were spelled out a little more.

đź‘Ť 3
pfeodrippe17:08:57

I'm starting to study Fulcro, I have a button which creates a new Component. What's the best way to make initial state as :initial-state only runs at the start of the app? Maybe use pre-merge or merge/merge-component?

lgessler18:08:16

i've used pre-merge for this personally, the situation was that i had to initialize some props on every item in a list that wasn't loaded until after app setup. not positive that it's the recommended solution but i can't really think of a better way to init state on a component not present at startup

pfeodrippe20:08:38

Thank you o/

nivekuil20:08:37

how can I find out why fulcro is sending the exact same pathom query 3 times for the same route?

lgessler21:08:27

are you seeing this on the browser side or the server side?

nivekuil21:08:06

I'm seeing it in fulcro inspect, and on the browser (seems to flicker?)

nivekuil21:08:40

specifically what's going on is I have a df/load! in :will-enter -- likely not the right way to do it, but I'm curious if I can track that behavior somehow

lgessler21:08:23

if you're using it along with dr/route-deferred that is the standard way to do it. can you share your :will-enter?

lgessler21:08:13

should look sth like this for a global pathom query:

(fn [app _]
  (dr/route-deferred
    ident
    #(df/load! app :global-query ProjectListItem
               {:target               (conj ident :my-prop)
                :post-mutation        `dr/target-ready
                :post-mutation-params {:target ident}})))

nivekuil21:08:39

ah, using route-deferred stops the chatter. I was trying out df/load! followed by route-immediate because it seemed to be substantially more responsive

lgessler21:08:49

hm, it is weird that that results in multiple queries. my only guess is that maybe dr internally can cause :will-enter to fire multiple times

nivekuil21:08:21

:will-enter (fn [app {:keys [view-param]}]                  (let [view-id [:view/id (uuid view-param)]]                    (df/load! app view-id View)                    (dr/route-immediate view-id)))

lgessler21:08:25

another way to do it would be to put the load wherever you trigger the route change but i'm not sure if that'd be ergonomic for your case

lgessler21:08:38

(and then route immediately in the will enter)

nivekuil21:08:05

and really, it does still seem to be more responsive. I think I'm doing routing fundamentally wrong somehow because it seems like the new component getting loaded co-exists simulatenously for an instant with the old one

nivekuil21:08:45

where my routing logic is just calling pushy/set-token! inside a mutation (and I guess pushy calls dr/change-route! in history

nivekuil21:08:42

yeah I think the router would have to know about the UI components and that seems weird

tony.kay21:08:13

In general the control of I/O should be in centralized logic, I recommend UISM, and not tied exclusively to the UI component. “Routing” in Fulcro is really meant to be nothing more than “UI query update, render correct thing”. Getting the event from that can trigger I/O of course, but typically your logic needs will surpass the routing concern. E.g. what if you just routed there, went elsewhere, and came back? Reload/caching logic needs its own layer…routing should just be saying “I’m here now” to a more centralized bank of well-designed logic IMO

cjmurphy21:08:48

So if you are thinking of using route-deferred , good time to think up a UISM solution. Is that the general advice?

tony.kay21:08:37

in a “real app”, it’s what I almost always do…but these days mostly I use RAD’s pre-written UISM machines, so I rarely have to write the logic by hand again.

tony.kay21:08:23

I’m working on a mobile app this minute, but I have no UI plugin for RAD yet…still, I’m using a defsc-form, which in turn gives me all the routing, loading, saving…all I have to do is write some UI tags.

tony.kay22:08:09

you typically only have 1-3 patterns in a given type of app…and UISM is designed to not need to know the specifics of UI…UI elements are just actors in the model. So, reuse is quite good.

đź‘Ť 3
nivekuil22:08:15

oh, interesting. I hadn't thought of a webpage as a state in a state machine before, but that makes a lot of sense, especially wrt caching.. another fun fulcro thing to learn. Thanks!

lgessler22:08:02

go long on UISMs I say, there's no abstraction like it that i know of in JS frameworks

bbss05:08:31

@U49U72C4V in the JS world Xstate seems popular. They do/require a bit more than UISM's but do get cool visualization features as a bonus.