I have a LiveComponent that I use in multiple locations in my app. I want to flash a message from within handle_event. As far as I understand I need to redirect after I flash, to flush the flash to the connection/socket. Like this:
def handle_event("do_something", _, socket) do
# do something here
{:noreply,
socket
|> put_flash(:success, "Success")
|> push_redirect(to: <TODO>)
end
What do I put in the to: in the redirect, so it’s always the “current path”, no matter where I use the component? Do I need to pass down the current path from the handle_params of the parent, or is there a smarter way?