Fork me on GitHub
#biff
<
2022-05-22
>
theeternalpulse20:05:37

Hi there, read through the docs and am looking to start creating my app and was wondering if there's a strategy for dealing with client app state using biff and it's many components. In my case I have a page that will have many text areas with some additional info that a user can attach to them and the user can add as many as possible before actually performing any crud operation on it.

Jacob O'Bryant20:05:43

the general approach is to keep client side state as lean as possible and ideally within the DOM. you could take a look at the docs for htmx (https://htmx.org/) and Hyperscript (https://hyperscript.org/); biff doesn't add anything on top of them. and of course you can always add in some plain Javascript if needed. I do that every now and then. in this case, the easiest thing might be to have an Add button that triggers an htmx request, so you can render a new block of input fields on the server and insert them into the DOM. however that would introduce a needless network request and the associated latency. so I might just use plain Javascript to render and insert the fields. in either case, a Remove button could be implemented with Hyperscript pretty easily.

theeternalpulse23:05:05

To clarify, do you mean plain old JavaScript in the static js file for the site? No clojurescript?

Jacob O'Bryant00:05:53

yeah, that's what I mean. You can use clojurescript, but you'll have to wire it up yourself; biff doesn't provide cljs out of the box.