Fork me on GitHub
#fulcro
<
2022-11-14
>
roklenarcic10:11:05

Can I modify a state transition in UISM before I run it? Something like:

(update-in auth-state-machine
                                 [::uism/states :state/logged-out ::uism/events :event/logged-in ::uism/handler]
                                 #(comp on-login %))
It seems that the old version is being called. on-login is never called

tony.kay13:11:00

There’s a central registry of state machines

tony.kay13:11:11

you have to do that in the defstatemachine

tony.kay13:11:49

The state machine def doesn’t get passed around anywhere, so the code has to look it up

tony.kay13:11:02

when you start it, only its ID is copied

roklenarcic17:11:22

I have a property called ::all-categories which is a list of all categories, used in multiple places in the app. What is the best way to utilize it? Should I query for [::all-categories '_] in components?

tony.kay17:11:18

If it is truly global, then that is a reasonable thing to do. You can also add it to the shared data.

tony.kay17:11:50

Read carefully. Shared is best for things that change rarely. They don’t have the same UI update guarantees as link queries. In general I use link queries.

❤️ 1
roklenarcic19:11:09

It is very often that in Fulcro Inspect Transaction view I see State Before and State After be same revision (e.g. when looking at internal-load! ), is this normal? My diff added diff removed are nil on all transactions. I am trying to track down why a property got removed.

tony.kay19:11:22

Unfortunately this is a bug in Inspect I introduced when I optimized it to be faster some time ago. I have not had time to fix it.

tony.kay19:11:17

Normalization is not broken, so you can stop barking up that tree. You should look at: What query did you send (network tab) and what response did you receive. If they match up then things will work.

roklenarcic19:11:54

When I load a picker option it deletes po/query-key from the DB.

tony.kay19:11:54

i.e. load works. I’d know if it didn’t because i use Fulcro in 300k lines of production apps 😄

tony.kay19:11:45

picker options are normalized…there may be some additional login in RAD picker support (don’t remember) that is removing the key from the db

tony.kay19:11:51

RAD uses pickers by loading the entire table via a link query. It never uses the load key

roklenarcic19:11:53

I have ::all-categories loaded, the picker uses same load to load them into options cache, but it deletes the ::all-categories value at the root of DB for some reason

roklenarcic19:11:58

the load works as expected

roklenarcic19:11:22

by that I mean I get the expected value from backend

tony.kay19:11:46

if the load “targets” them, then load removes the root key after the relocation

roklenarcic19:11:46

that would explain that

tony.kay19:11:04

pickers DO target their results

tony.kay19:11:28

see picker-options/load-picker-options!

tony.kay19:11:15

The link query that RAD uses for picker options is

[::picker-options/options-cache '_]

roklenarcic19:11:23

kinda unfortunate that nukes the value already in place

tony.kay19:11:59

The fact that it puts it in root at all (when targeting is present) is a legacy thing

tony.kay19:11:10

if you actually want it in root, you can always include that as one of the targets, but the general idea is that top-level keys should not pollute the root unless it is intended.

roklenarcic19:11:51

so I should load target ::all-categories into all 3 components that need it?

tony.kay19:11:19

are you using picker options?

roklenarcic19:11:20

probably best, as I stop using link queries

roklenarcic19:11:25

in one part yes

tony.kay19:11:36

so, you could manually write that load so that you don’t target

tony.kay19:11:10

up to you and which is less complex for your use-case

roklenarcic19:11:52

Yeah I have to think about that

roklenarcic19:11:55

I don’t know what you mean by manually writing that load though. Picker does its own load that I cannot affect target-wise as seen in docs:

* `load-options` - Additional options you wish to pass to the load (optional). Only used if the cache was missing or
   stale for the options. Currently you cannot use `:target`, `:params`, or `:post-action`. `::picker-options/remote` can
   be used to select the load remote.

tony.kay19:11:41

I mean read the source of that, and just do what it does…it just issues a load

tony.kay19:11:28

I guess if you’re relying on RAD to do the load, then that doesn’t work…you could pull the entire table like RAD reports do

tony.kay19:11:33

(link query I mentioned earlier)

roklenarcic19:11:51

yes and it does have a non-trivial post-action

tony.kay19:11:22

or if you’re in the body of a report, you already have that

roklenarcic19:11:01

Thanks I’ll mull this over