Hi there, im pretty new to Elixir, Phoenix and Liveview. I come from an app developer background.
Im having a little hard time, wrapping my head around, how to properly compartmentalize (is that a word?) an advanced view, and which responsibilities falls to the liveview, and which falls to the live_component.
How the view was structured: (several live views, each implementing the header, above its own content)
And how im thinking of structuring it now:
Because every tab was its own liveview previously, the presentation of specific modals, were each handled by their own “tab” liveview (using patch, and toggling visibility using live_action).
When refactoring this I want to rewrite the old live views into live_components. However, im unsure of wether or not it makes sense keep the toggling of the modals, in the components, or if this functionality should be moved to the “mother” liveview.
My gut feeling and experience from other platforms and languages, tells me that a “view” should handle navigation, and that its best to delegate this responsibility to the controller. However there are a lot of modals, which would mean that my liveview, will get cluttered by many functions. (there will be 9 tabs)
My current plan was to have the component be “dumb” and just fire a send self() from it, like what is shown in the docs here: docs
But if im piping the events through the component to the liveview, does it even make sense for it to be a live_component, or could I just as well use a function component? (im a little lost on when to use what, and for what purpose)
I need good suggestions for how to architecture a screen like this, and comments about best practice in the phoenix/liveview world.
Bonus info: This is an admin tool, where each tab is a specific view, for working and tweaking specific parts of a project.