Search documentation of Plushie

# Plushie.Event.AsyncEvent (Plushie v0.7.2)

Copy Markdown View Source

Results from `Plushie.Command.task/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()

## Types

# t()

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