matrix

awb99 2024-10-28T14:48:16.446809Z

Hi! I have read a lot of @hiskennyness articles and code. It is pretty amazing that a single person can build a glitch-free dag model, and make multi-platform ui using it. I do have few questions though: 1. Lets say I use matrix to render a table for which I will dynamically add and remove rows. In react for a scenario like this I would add a index-id key, so that in updating the dom elements, the already existing dom elements can be reused. This is a sort of performance trick. Does matrix do a similar thing? 2. I am looking for an example in which the individual components do data-fetching. Please forgive me in saying "components" - I know that for matrix there is no such thing as a component;l however I still would create different functions that render different types of elements, so for me this is the component. Why I ask for data-fetching? Well, as I can tell all the rendering in matrix is synchronous, so when a cell updates then the dom elements that depend on this cell re-render. But for apps that need to do lots of data fetching, there should be some kind of pattern that makes sense. And I have not seen that. 3. I would like to try out matrix, and I want to do this in a bigger app (just a demo will not help me to much); and so I am thinking about how to use matrix together with my existing reagent app. To use matrix from reagent is simple, as reagent gives me a ref to a dom node, so that can be used to have part of the ui being manage by matrix. The other way I dont know how to do. So basically what I am looking for is getting a ref to a dom element that is created by matrix, which I can manipulate as I like from outside matrix. Thanks a lot!

kennytilton 2024-10-28T15:04:48.247549Z

Thx for the kind words! Re #1: Yes, but we have to do more than supply a key. There is a small API if you will in which we use a certain container and specify a buikder and a key function which can be more flexible. I rarely need it, but it is there. And now we are not nagged by the framework over a three elemet list not having a key. 🙂 Re #2; Having a little trouble understanding this one. Let's home in on "But for apps that need to do lots of data fetching, there should be some kind of pattern that makes sense.". Well, also "Well, as I can tell all the rendering in matrix is synchronous". I do have a couple of examples that go out and pull data from http://FDA.gov when a text field changes, when displays the results. And all that happens asynchronously. Anyway, please expand on this and we'll sort it out. Re #3: Getting the DOM ref from Matrix is part of the MX API, just do not have it handy, and I have been doing Flutter lately. But, yeah, MX always knows the DOM of a MX element. Only general concern is mixing two reactive systems, but I did do a bunch of Reagent one one project and from what I remember it should be doable. Just curious: what role do you see for MX given Reagent is already on the job? Thx for the interest! Funny you came along, I have been thinking of promoting the HTML version of Matrix. Things are a bit quiet in CLJD. Cheers, kt

awb99 2024-10-28T18:17:56.857639Z

Wow!! Thanks @hiskennyness I didnt expect an answer; and for sure not so fast!

awb99 2024-10-28T18:18:35.639749Z

#1 could you direct me to the right place? To me it is relevant because I believe performance suffers a lot if I dont use that.

awb99 2024-10-28T18:19:02.048259Z

#2 The example of the http://fda.gov site would be fantastic!

awb99 2024-10-28T18:20:50.388559Z

#3: I believe that the time of reagent is over. (Sorry to be so frank; I still use reagent, and it has been very nice to use). But it was designed before react had functional components. Now it is a sort of mess to deal with.

awb99 2024-10-28T18:21:43.890589Z

What I find very difficult to do in reagent is a simple data-loader pattern. So I have person-id 1, and then I want to do async fetch the person with id-1 and then render that with some ui component.

awb99 2024-10-28T18:22:32.831129Z

Perhaps I am stupid, and there are patterns that work for that. But I have spent a lot of time and couldnt find nice patterns.

awb99 2024-10-28T18:24:26.340899Z

I am following electric, but I havent made a switch to it, and will not use it, because it always requires a server.

awb99 2024-10-28T18:24:44.842719Z

I am searching for reactive-ui that can be both only on client in browser, and also used when there is a server around.

awb99 2024-10-28T18:25:06.777959Z

Ideally this is the only framework that is needed,

awb99 2024-10-28T18:25:20.925399Z

However, the react ecosystem is so huge, that it is very tempting to use libraries from it.

awb99 2024-10-28T18:26:58.252209Z

I also doubt that I could ever get glitch-free computations done with reagent.

awb99 2024-10-28T18:31:11.994699Z

I wrote an app that uses missionary to have lazy dags.

awb99 2024-10-28T18:31:51.162389Z

Right now I can watch part of the dag (so activate it), and forward it to a reagent ui for continuous display.

awb99 2024-10-28T18:32:09.480159Z

What I am thinking of doing is using matrix as a middleware beween missionary and the dom.

awb99 2024-10-28T18:32:22.511719Z

This saves me the time of writing what matrix did for the dom for missionary.

kennytilton 2024-10-28T18:55:42.071529Z

I have to run out for the rest of the afternoon (EDT) but will try to reply in depth later. Some quick Qs: So you like missionary but want to use the also reactive MX to manage the DOM? Is there sth Missionary does that MX does not, or is it just that you like Missionary and want to use that most of the time? I will find the right repo later, but you are looking for an RxTrak project that is the Todo standard, but treats a to-do as a drug to be checked on http://FDA.gov. Lots of bit rot, btw, so be leery of getting anything to run. 🙂 ps. Yeah, React has gotten quite prescriptive over the years. And it has been a moving target, though last I looked was a few years ago. Back later.

awb99 2024-10-28T19:00:22.322169Z

Missionary has resource manangement built into.

awb99 2024-10-28T19:00:59.070089Z

It allows me to build reactive functions in a very nice way.

awb99 2024-10-28T19:01:13.338649Z

But it does not have anything related to the dom.

awb99 2024-10-28T19:01:18.799299Z

It is just one side of the coin.

awb99 2024-10-28T19:02:26.538719Z

It also allows discrete and continuous streams.

awb99 2024-10-28T19:02:35.346309Z

Whereas matrix only does continuous.

awb99 2024-10-28T19:03:13.307669Z

For the dom it does not matter, as when the user is viewing your page, you will always see your page.

awb99 2024-10-28T19:03:35.118089Z

Whereas when you do transactions then discrete events matter.

awb99 2024-10-28T19:03:48.357679Z

But it is nice to have the two concepts in one library.

kennytilton 2024-10-28T22:15:22.721249Z

Here is the bit in rxTrak that looks up adverse events asynchronously when the "todo" title changes: https://github.com/kennytilton/web-mx-sampler/blob/002433cdc91243e9cc3ebe19db26849cc107f420/src/tiltontec/example/rxtrak/rx_list_item.cljs#L169 Other UI code watches the response property and fires when the response comes in, to display the results. More to come.

kennytilton 2024-10-28T22:21:05.063149Z

OK, the same demo uses the optimization to minimize a UI list rebuilding: https://github.com/kennytilton/web-mx-sampler/blob/002433cdc91243e9cc3ebe19db26849cc107f420/src/tiltontec/example/rxtrak/build.cljs#L132 I think I was just showing off the mechanism...well, I guess even though there would only ever be a hadful of "todos", if we did not optimize and the list rebuilt from scratch we would also re-fetch al the adverse events. Not good.

awb99 2024-10-28T23:40:26.342759Z

Thanks a lot @hiskennyness