rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.52k stars 106 forks source link

How would you go about creating a reactive component? #258

Closed joshcho closed 1 year ago

joshcho commented 1 year ago

I would like to have app-data (say, a list) and a rendering of that app-data which is reactive. Thus any changes to the app-data would result in change to the rendering. Is there a way to achieve this subscription mechanic elegantly in CLOG?

joshcho commented 1 year ago

I am looking at tutorial 29, which seems helpful. If there are any other resources, I would appreciate it.

rabbibotton commented 1 year ago

The idea behind CLOG is that you are focused on Lisp not the web. So how would you create a component that is reactive in Lisp? One way is using clog-presentations (what tutorial 29 is based on) the other way would maybe using various OO patterns the ultimately use the regular CLOG API. The issue is more about tracking changes to Lisp data.

It may be worthwhile developing a client side library (in parascript or js) for certain canned client side only "reactions" and I may do it at some point.

However, here is my philosophy, develop your app using the full server side model, 99% of the time is good as is, when the need for speed happens I optimize that specific functionality in straight JS. The speed of developing full server side and simplicity makes up for any time spent later on.

joshcho commented 1 year ago

Thank you. Will something like https://github.com/nklein/cl-reactive be helpful?

rabbibotton commented 1 year ago

I will take a look at it.

joshcho commented 1 year ago

Also, from what I am reading, with presentations you cannot have one-to-many relationship, i.e. from one lisp object to multiple elements on the webpage, is this correct?

rabbibotton commented 1 year ago

Sorry for delay, will be back on CLOG in a few days (had 3 grandsons born this last month).

Using the presentations stuff one to many has limits. I am not big into automagic things. If you give me a general idea of what you want to accomplish I think better to do that and than I can create something that fits that model.

I think worth us doing as despite my tendency towards a functional side, there is for sure a demand for something reactive (automagic changes to code). For example since CLOG is event driven I can create and alternative path to other event models as well.

So ideal for me (as I speak code far better than human), give me some pseudo code of how you would imagine code would look in your reactive model.

mmontone commented 1 year ago

I'm doing it like this at the moment: https://github.com/rabbibotton/clog/discussions/239 . I should have a look at cl-reactive too. Looks interesting.