Plushie.Event.AsyncEvent (Plushie v0.6.0)

Copy Markdown View Source

Results from Plushie.Command.async/2 tasks.

Fields

  • tag -- the user-defined atom tag from the command
  • result -- {:ok, value} on success, {:error, reason} on failure

Pattern matching

def update(model, %AsyncEvent{tag: :fetch, result: {:ok, data}}), do: ...
def update(model, %AsyncEvent{tag: :fetch, result: {:error, reason}}), do: ...

# Catch all async errors regardless of tag:
def update(model, %AsyncEvent{result: {:error, reason}}), do: ...

Summary

Types

t()

@type t() :: %Plushie.Event.AsyncEvent{
  result: {:ok, term()} | {:error, term()},
  tag: atom()
}