Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Aug 16, 2023
1 parent 6896f0d commit 8e6a32d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/phoenix_live_view/async.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ defmodule Phoenix.LiveView.Async do

@doc false
def cancel_async(%Socket{} = socket, %AsyncResult{} = result, reason) do
result.keys
|> Enum.reduce(socket, fn key, acc ->
Phoenix.Component.assign(acc, key, AsyncResult.error(result, reason))
end)
new_assigns = for key <- result.keys, do: {key, AsyncResult.error(result, reason)}

socket
|> Phoenix.Component.assign(new_assigns)
|> cancel_async(result.keys, reason)
end

Expand Down

0 comments on commit 8e6a32d

Please sign in to comment.