if_ok
if_ok if_ok is a small utility library that let's you create pipelines that expect ok tuples to continue in a very readable way.
An example how we can use this:
defmodule MyApp.DoStuff do
import IfOk
alias MyApp.Repo
def broadcast_out(item) do: {:ok, item}
def update(changeset, user) do
changeset
|> authorize(user, :update)
|> if_ok(&Repo.update)
|> if_ok(&broadcast_out)
|> if_ok(:ok)
end
endInstallation
The package can be installed as:
-
Add
if_okto your list of dependencies inmix.exs:
```elixir
def deps do
[{:if_ok, "~> 0.1.0"}]
end
```-
Ensure
if_okis started before your application:
```elixir
def application do
[applications: [:if_ok]]
end
```