fulcro

Yaw Odame 2024-10-10T17:28:27.106139Z

Is it possible to have a subform without an ident? I noticed the fulcro book subforms have some db/id. In my case, I have an address component in my schema for an entity.

đź‘€ 1
tony.kay 2024-10-10T18:18:27.894169Z

how would an address be related to a parent if it doesn’t have an ID? Of course it needs an id and ident.

tony.kay 2024-10-10T18:18:52.895489Z

you CAN use a native ID (you don’t have to add a UUID, if that’s what you mean)

tony.kay 2024-10-10T18:19:14.486789Z

but in RAD you alias the :db/id to :address/id so that it understands which kind of entity to expect (resolver-wise)

Yaw Odame 2024-10-10T18:36:17.904409Z

This is an example data structure I fed into my form. I have a form config join in the Person form component with a join on the Address form component. Unfortunately, there's no ident for the address.

{:person/primary-address [:address/country-code
                          :address/line1
                          :address/line2
                          :address/locality
                          :address/subdivision-code
                          :address/postal-code]}

tony.kay 2024-10-10T19:08:29.178159Z

you will need an :address/id, which you can map to :db/id (in Datomic) or native row ID in SQL, etc. And it will need an ident, as I said. How can you make a join in a db without an iD? Unless you mean you want it to be fields in the parent entity/row (to-one) without an actual ref relationship. Then that is possible, but you’d then need the parent ID to appear in the child (with the parent’s ident even) so that things would get normalized properly. In other words it is allowed for a child UI component to share the “data space” of the parent.

genekim 2024-10-10T17:28:34.615019Z

Good morning! I have a question about the queues behind comp/transact! and df/load. I currently have a RAD report that renders a bunch of rows. I have an “Analyze All” button, that for each row, triggers a sequence of transactions with {:parallel? true} that makes calls to an LLM that can take tens of seconds to run. While the transactions run, I go to the next page, and all my component df/loads {:parallel true} get queued up behind the LLM transactions, which basically makes my app unusable until all the LLM operations finish. How do I get these df/loads to take priority over the comp/transact? I’ve tried the df/load with and without {:parallel?} Thank you! (I saw the discussion here, which seemed relevant, but couldn’t quite grok where it all ended up. https://clojurians.slack.com/archives/C68M60S4F/p1616460727115900?thread_ts=1616458487.111800&cid=C68M60S4F)

tony.kay 2024-10-10T18:22:08.324759Z

What you are more likely running into is the the browser itself limits parallel requests

tony.kay 2024-10-10T18:22:27.160319Z

You’ve switched from using Fulcro’s queues, and are instead hitting the hard limit of the browser itself.

tony.kay 2024-10-10T18:23:39.546109Z

The answer is to write a single read that can somehow get your rows as a single request, so they don’t clog the queue… same with the transactions. Parallel takes them OUT of Fulcro’s control. Submit a single transact with the multiple calls as a SINGLE call to transact, which will result in a SINGLE network call.

tony.kay 2024-10-10T18:26:30.354559Z

this will mean a lot more work on your part. You could also try the read-combining transaction processing (which can be plugged in). That support tries to combine multiple loads into a single network request, but depending on how it gets invoked it may fail to help. You’re doing a case that goes beyond the basics of what Fulcro can do with the pre-canned facilities. As soon as you start doing large numbers of parallel reads/writes you’re going to run into problems because of this browser limitation. That said, you can also use the low level load-mutation to send custom batched loads…and as I said you can submit many mutation calls with a single transact. Moving these things down to single requests will get you past the browser limitations.

genekim 2024-10-10T20:51:26.818909Z

That is so helpful — thank you! I’ll ponder the potential solutions and will post what I come up with. HAGW!

genekim 2024-10-10T20:53:35.432869Z

Do I understand correctly that websockets might be a way to send data asynchronously from server back to client, to send client database updates?

tony.kay 2024-10-10T23:43:22.819049Z

yes, that is what they are good at

Eric Dvorsak 2024-10-12T08:15:07.285069Z

I use websockets for llm based requests (and actually anything that takes more than a second)

Eric Dvorsak 2024-10-12T08:16:47.107049Z

It can be the browser but it can also be the backend, for most webservers if you have more concurrent requests than threads it will queue up. So if all your threads are clogged with slow llm requests your backend becomes completely irresponsive

Eric Dvorsak 2024-10-12T08:17:53.299179Z

Thats why some support async requests/reponses or use the new light threads to remove that limitation

Eric Dvorsak 2024-10-12T08:18:12.818569Z

(eg latest http-kit)

tony.kay 2024-10-12T14:11:51.750919Z

For sure if you’re doing back-end parallel work where it isn’t CPU bound you should try to use async mechanisms. Beware light threads: if they get CPU bound they don’t work the way you think they will. They won’t context switch correctly (they rely on blocking calls for interruption). The async support, however, works very well in http kit for large parallel loads where I/O tends to cause unnecessary server clogging.