helf v0.0.1 HELF.Flow
Link to this section Summary
Functions
Stores a callback to be executed at the end of the with
, no matter if it succeeds or fails
Stores a callback to be executed if the with
fails
Stores a callback to be executed if the with
succeeds
Link to this section Functions
Stores a callback to be executed at the end of the with
, no matter if it succeeds or fails
Eg:
flowing do
with on_done(fn -> IO.puts "The flow is completed" end),
{:ok, value} <- Map.fetch(%{a: 1}, :a)
do
flowing do
with on_done(fn -> IO.puts "The other flow is completed" end),
{:ok, value} <- Map.fetch(%{a: 1}, :b)
do
:gotcha
end
end
end
end
Stores a callback to be executed if the with
fails
Eg:
flowing do
with on_fail(fn -> IO.puts "Operation failed" end),
{:ok, value} <- Map.fetch(%{a: 1}, :b),
on_success(fn -> IO.puts "Succeeded and got #{inspect value}" end)
do
:gotcha
end
end
Stores a callback to be executed if the with
succeeds
Eg:
flowing do
with on_fail(fn -> IO.puts "Operation failed" end),
{:ok, value} <- Map.fetch(%{a: 1}, :a),
on_success(fn -> IO.puts "Succeeded and got #{inspect value}" end)
do
:gotcha
end
end