I’ve seen a few posts discussing how to organize components, but what is best practice when it comes to organizing the liveviews themselves?
How much should I put in each liveview (and use @live_action) in the view to “toggle” whats shown, and when to break it out in a new liveview? Are there any example liveview projects that are more complex than say a todo-app - i.e something handling multiple nested “resources”?
For instance, it is not immediately clear to me when looking at the router (at 3:10) in Phoenix LiveView Crash Course - YouTube what guiding principles decide what ends up in (for instance) MemberSubscriptionLive.Index vs MemberSubscriptionLive.Edit.
I don’t know if this is idiomatic, but the way I think of it is:
When it’s the same “view”, mostly the same page, but slightly modified, for example a component rendered with different params, or “toggled” to be shown or hidden at all as you suggested, but the event handlers and are mostly the same - I would use @live_action.
However, when, suppose, “Index” and “show” actions differ too much from each other and I find that too much of their logic get mixed in the same LiveView, then it’s probably a good idea to break it into separate LiveViews.
At first we could delegate handle_events to LiveComponents (phx-target={@myself}) but, for example handle_info is still need to be in parent LiveView