Reply (Reply v1.1.0)
View SourceLets you pipe the reply in a Phoenix LiveView.
Just write socket |> assigns |> ok() in mount or socket |> assigns |> noreply() in handle_* functions insted of dealing with tuples.
Summary
Functions
Transforms a piped reply into a {:noreply, socket} response tuple.
Transforms a piped reply into a {:ok, socket} response tuple.
Transforms a piped reply with payload into a {:reply, payload, socket} response tuple.
Functions
Transforms a piped reply into a {:noreply, socket} response tuple.
Examples
def handle_event("update", %{"id" => id}, socket) do
socket
|> assign(:post, Blog.get_post!(id))
|> noreply()
end
Transforms a piped reply into a {:ok, socket} response tuple.
Examples
def mount(_params, _session, socket) do
socket
|> assign(:posts, Blog.list_posts())
|> ok()
end
Transforms a piped reply with payload into a {:reply, payload, socket} response tuple.
Examples
def handle_event("update", %{"id" => id}, socket) do
{:ok, post} = Blog.get_post!(id)
socket
|> assign(:post, post)
|> reply(%{last_update: post.updated_at})
end