Applies LiveView-specific side effects to the socket based on the result
of an Alva.Dispatcher.dispatch/3 call and a requested strategy.
Supported Strategies
{:stream_insert, key}- Inserts data into aPhoenix.LiveViewstream.{:stream_delete, key}- Deletes data from aPhoenix.LiveViewstream.{:assign, key}- Assigns data to the socket.{:push_event, event_name}- Pushes aPhoenix.LiveViewevent to the client.{:navigate, to}- Navigates to a new LiveView path.{:patch, to}- Patches the current LiveView path.{:custom, module}- Delegates to a custom module'shandle_result/2.{:reply, :data}- Default. Returns data without side effects.
Summary
Functions
Transforms the dispatcher result into a LiveView return tuple {:reply, map, socket}
and applies the specified side effect to the socket.
Functions
Transforms the dispatcher result into a LiveView return tuple {:reply, map, socket}
and applies the specified side effect to the socket.
Examples
iex> result = %{ok: true, data: %{id: 1, name: "Test"}}
iex> Alva.Result.apply(result, socket, strategy: {:stream_insert, :students})
{:reply, %{ok: true, data: %{id: 1, name: "Test"}}, socket_with_stream_inserted}