View Source PipeHelpers (PipeHelpers v1.0.2)
Helper for piping data
Link to this section Summary
Functions
Wrap into noreply tuple (genserver and phoenix socket format)
Wrap into ok tuple
Wrap into tuple pair
Wrap into reply tuple (genserver and phoenix socket format)
Wrap into tuple rpair
Tap only if ok tuple
Tap only if value match
Then only if ok tuple
Then only if value match
Unwrap from a tuple pair
Link to this section Functions
Wrap into noreply tuple (genserver and phoenix socket format)
example
Example
iex> state = "gen server state"
...> state |> noreply()
{:noreply, "gen server state"}
Wrap into ok tuple
example
Example
iex> socket = "socket"
...> socket |> ok()
{:ok, "socket"}
Wrap into tuple pair
example
Example
iex> 1 |> pair(2)
{2, 1}
Wrap into reply tuple (genserver and phoenix socket format)
example
Example
iex> state = "gen server state"
...> r = "reply"
...> state |> reply(r)
{:reply, "reply", "gen server state"}
Wrap into tuple rpair
example
Example
iex> 1 |> rpair(2)
{1, 2}
Tap only if ok tuple
example
Example
iex> {:ok, "somedata"} |> tap_ok(fn -> "only executed when {:ok, ...}" end)
{:ok, "somedata"}
iex> {:ok, "somedata"} |> tap_ok(fn _val ->
...> _ = "only executed when {:ok, ...}"
...> "val is available as optional argument"
...> end)
{:ok, "somedata"}
Tap only if value match
example
Example
iex> true |> tap_on(true, fn -> "only executed when true" end)
true
Then only if ok tuple
example
Example
iex> {:ok, "somedata"} |> then_ok(fn -> "only executed when {:ok, ...}" end)
"only executed when {:ok, ...}"
iex> {:ok, "somedata"} |> then_ok(fn val ->
...> _ = "only executed when {:ok, ...}"
...> _ = "val is available as optional argument"
...> val
...> end)
"somedata"
Then only if value match
Unwrap from a tuple pair
example
Example
iex> {:ok, 1} |> unpair()
1