Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Aug 11, 2023
1 parent 1d20557 commit 0067372
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/phoenix_live_view/async_result.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ defmodule Phoenix.LiveView.AsyncResult do
alias Phoenix.LiveView.{AsyncResult, Socket}

@doc """
TODO
Defines a new async result.
By default, the state will be `:loading`.
"""
def new(name) do
new(name, [name])
Expand All @@ -113,35 +115,38 @@ defmodule Phoenix.LiveView.AsyncResult do
end

@doc """
TODO
Updates the state of the result to `:loading`
"""
def loading(%AsyncResult{} = result) do
%AsyncResult{result | state: :loading}
end

@doc """
TODO
Updates the state of the result to `{:error, {:canceled, reason}}`.
"""
def canceled(%AsyncResult{} = result, reason) do
error(result, {:canceled, reason})
end

@doc """
TODO
Updates the state of the result to `{:error, reason}`.
"""
def error(%AsyncResult{} = result, reason) do
%AsyncResult{result | state: {:error, reason}}
end

@doc """
TODO
Updates the state of the result to `{:exit, reason}`.
"""
def exit(%AsyncResult{} = result, reason) do
%AsyncResult{result | state: {:exit, reason}}
end

@doc """
TODO
Updates the state of the result to `:ok` and sets the result.
The `:ok?` field will also be set to `true` to indicate this result has
completed successfully at least once, regardless of future state changes.
"""
def ok(%AsyncResult{} = result, value) do
%AsyncResult{result | state: :ok, ok?: true, result: value}
Expand Down

0 comments on commit 0067372

Please sign in to comment.