SocketHelpers

Simple library that adds a piping possibility for easy returning from liveview

Imagine

socket =
  socket
  |> assign(valid: true)
{:noreply, socket}

to write like:

socket
|> assign(valid: true)
|> noreply()

Looks cleaner ?

Examples

iex(2)> socket = %{}
%{}
iex(3)> socket |> ok()
{:ok, %{}}
iex(4)> socket |> noreply()
{:noreply, %{}}

Installation

If available in Hex, the package can be installed by adding socket_helpers to your list of dependencies in mix.exs:

def deps do
  [
    {:return_helpers, "~> 0.0.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/socket_helpers.