View Source SocketReply (SocketReply v0.1.0)

SocketReply lets you pipe the reply in a Phoenix LiveView. Just write socket |> assigns |> reply in mount and handle_* functions insted of dealing with tuples.

Summary

Functions

Transforms a piped reply into a response tuple.

Transforms a piped reply with data into a response tuple. Works with maps and keyword lists.

Functions

Transforms a piped reply into a response tuple.

Examples

def mount(_params, _session, socket) do
  socket
  |> assign(:posts, Blog.list_posts())
  |> assign(:post, nil)
  |> reply(:ok)
end
Link to this function

reply(socket, term, keyword)

View Source

Transforms a piped reply with data into a response tuple. Works with maps and keyword lists.

Examples

def handle_event("update", params, socket) do
  {:ok, post} = Blog.get_post!(id)

  socket
  |> assign(:post, Blog.get_post!(id))
  |> reply(:reply, %{last_update: post.updated_at}})
end