reagent

reefersleep 2023-10-25T22:13:59.368169Z

I'm curious about the code in reagent that handles form-2 components. Can anyone point me to the part of reagent source that "resolves" form-2 components into their inner fn?

reefersleep 2023-11-01T16:09:34.916379Z

Thank you very much for taking your time to point this out, @jahson. I still haven't quite wrapped my head around it, because I haven't had the time to really read through and understand the whole thing. I thought I was definitely on the right track in this function, where some recursion happens that I understand (resolving each first element of a hiccup vector), and the function docstring explicitly mentions form-2 components - actually, specifically, it mentions recursively resolving until the render result doesn't evaluate to a function. But from my somewhat cursory read, I couldn't figure out if this fn was on the main path for reagent, or whether it was some kind of special case. I assume, since you pointed me elsewhere, that my "spot" is the latter; a special case, and not part of the central render logic. https://github.com/reagent-project/reagent/blob/a14faba55e373000f8f93edfcfce0d1222f7e71a/src/reagent/impl/component.cljs#L72 https://github.com/reagent-project/reagent/blob/a14faba55e373000f8f93edfcfce0d1222f7e71a/src/reagent/impl/component.cljs#L99

2023-11-01T18:53:21.677359Z

The easiest way to check the actual call path would be just use something like leiningen’s checkout dependencies (https://codeberg.org/leiningen/leiningen/src/branch/stable/doc/TUTORIAL.md#user-content-checkout-dependencies) to use reagent version with added logs.

🙌 1
reefersleep 2023-11-01T19:13:28.638099Z

You're so right. What better way than to literally step through the code.

2023-10-26T09:46:29.209179Z

Though I’m not sure what “resolve” means for you.

reefersleep 2023-10-26T12:29:00.428999Z

Hmmm I don't think that's what I was looking for. Essentially, as I understand it, form-2 components are "just" a special case of a function returning a function. You could also have that function return a function, and so on, and on and on, until you have something that returns Hiccup instead of a function. To produce a Hiccup tree, reagent must somehow resolve all of these functions that returns functions into Hiccup.

reefersleep 2023-10-26T12:30:32.030219Z

So, what I mean by "resolve" is; dive down the fns until they reach the fn that returns Hiccup, then have that fn be the rendering fn until the component is unmounted (or whatever the wording is).