View Source PipeHelpers (PipeHelpers v1.0.0)

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()

Wrap into ok tuple

example

Example

iex> socket = "socket" ...> socket |> ok()

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)

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)

iex> {:ok, "somedata"} |> tapok(fn _val -> ...> = "only executed when {:ok, ...}" ...> "val is available as optional argument" ...> end)

Link to this function

tap_on(result, value, fun)

View Source

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"} |> thenok(fn val -> ...> = "only executed when {:ok, ...}" ...> _ = "val is available as optional argument" ...> val ...> end) "somedata"

Link to this function

then_on(value, value, fun)

View Source

Then only if value match

Unwrap from a tuple pair

example

Example

iex> {:ok, 1} |> unpair() 1