Hi friends, if you want to create some complex components for example nested and tree drop down select box with search and etc! what option you select?
For example I do not want to send everything from server to client and if I use hook with pure JS, it is not easy to manage for examples more than 200 components (LiveView JS module is good for basic component, not for managing client state edit DOM + project structure even do the limit function in client side not server side)
I see petal using alpine JS or some friends using ReactJS, VueJS and etc.
I just need your suggestion especially a way that is light and developer friendly. imagine you have about 200 components(some of them stateless and the other stateful in client side).
I really need this so that Elixir Developer doesn’t feel like I’m using frontend js frameworks in phoenix LiveView again.
Sometimes it happens that the Alpine data in a LiveComponent does not get initialized, so you need to have a simple hook initializing it yourself.
In certain cases, you even need to do this on updates (not just on mounted), or otherwise the JS code crashes. Having to do this on updates may be an issue for in such cases (and I am talking about really complex components e.g. LiveComponents within a stream within LiveComponents within a stream, …) the data that gets initialized this way with your hook also gets reset.
Personally, I have managed to circumvent all the issues and the app is working really well in a staging environment (AWS/Kubernetes) and overall, I am satisfied with AlpineJS despite those issues with the integration.
Also, I have agreed with an AlpineJS library developer to check a demo of mine once LV 1.0 final is out, so we can at least understand if it’s really a LV issue or an Alpine issue and if possible to make them work smoothly again.
I use Alpine and not svelte because it was given to me as a requirement and at the time I started using it neither myself nor the client were aware of a viable LV-svelte integration (still not sure if there was one).
We’ve had good success using Custom Elements AKA Web Components as a means for integrating client JS with LiveView. We’ve put out LiveElements as a library to make this process easier.
As my repeated question, why you do not select svelte or something similar? especially for a page that has complex state!? because web-component as my experience is just as organiser to manage better in filing and prevent duplicating !! not for state and etc, the other one should be managed with listeners manually
In general, I’m letting LiveView manage the state and pass it in to the components, which then dispatch (possibly custom) events to be handled in the LiveView. LiveElements helps by both serializing complex props as json, and sending up custom events to LV.