I’m building my first app with LiveView, and the scaffolding generates that really nice
live_modal to render the FormComponent of my resources so one can
:edit it from views like the
With my app growing, I’m wanting to make a different LiveComponent for “list of my resource” (since it shows up in many places — the index view, but also of subresources and parent resource pages have “associated X’s” in a list) and I’d like to preserve the “edit/create from here” functionality.
Unless I’m misunderstanding, if I make the component stateless, then every LiveView that includes it will need to handle actions like
delete, potentially duplicating a lot of logic. But if I make the component stateful, I have to do a “threading” of
@live_action from the parent to the child while also targeting events to
@myself, and losing the URL-ability of
live_redirect, and maybe adjusting
live_modal since it has a
return_to: field that’ll depend on who called it (and adjusting the router to add an edit action…).
I guess, as I’m breaking out my first LiveComponent, I wonder if I’m missing a simpler way to architect this, or if I’m trying to do something unreasonable?
Thanks for any help, happy to elaborate if this isn’t clear