Reply to a an event from a hook.
https://hexdocs.pm/phoenix_live_view/js-interop.html#client-hooks
For example, in my hook in mounted()
mounted() {
...
// push event to liveview after handle is moved
this.slider.on("change", (values, handle) => {
this.pushEvent("scroll_to_time", { mins: values[handle] }, (payload) => {
this.slider.set(payload.mins);
});
});
...
and in my liveview:
def handle_event("scroll_to_time", %{"mins" => mins}, socket) do
...
{:reply, %{mins: mins}, socket}
end