View Source Rephex.AsyncAction.Base behaviour (rephex v0.1.1)

Summary

Callbacks

After the async action is resolved, this callback will be called.

Before the async action starts, this callback will be called.

Generate failed value. This value will be set to AsyncResult via AsyncResult.failed/2.

Get initial progress. This value will be set synchronously before the async action starts.

This callback will be implemented by using.

Types

@type exit_reason() :: any()
@type failed_value() :: any()
@type payload() :: map()
@type progress() :: any()
@type result_path() :: [term()]
@type state() :: map()
@type success_result() :: any()

Callbacks

Link to this callback

after_resolve(t, result_path, arg3)

View Source (optional)
@callback after_resolve(
  Phoenix.LiveView.Socket.t(),
  result_path(),
  {:ok, success_result()} | {:exit, exit_reason()}
) :: Phoenix.LiveView.Socket.t()

After the async action is resolved, this callback will be called.

Link to this callback

before_start(t, result_path, payload)

View Source (optional)

Before the async action starts, this callback will be called.

Link to this callback

generate_failed_value(result_path, exit_reason)

View Source (optional)
@callback generate_failed_value(result_path(), exit_reason()) :: failed_value()

Generate failed value. This value will be set to AsyncResult via AsyncResult.failed/2.

Link to this callback

initial_progress(result_path, payload)

View Source (optional)
@callback initial_progress(result_path(), payload()) :: progress()

Get initial progress. This value will be set synchronously before the async action starts.

@callback options() :: %{optional(:throttle) => non_neg_integer()}

This callback will be implemented by using.

Link to this callback

start_async(state, result_path, payload, function)

View Source
@callback start_async(
  state(),
  result_path(),
  payload(),
  (progress() -> nil)
) :: success_result()

Start async action.