Skip to content

Commit

Permalink
Doc update for Phoenix.LiveView.stream_insert/4 (#3198)
Browse files Browse the repository at this point in the history
* Update phoenix_live_view.ex

* Update phoenix_live_view.ex

* Update phoenix_live_view.ex
  • Loading branch information
balexand committed May 15, 2024
1 parent 6648f77 commit 76cb858
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/phoenix_live_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,9 @@ defmodule Phoenix.LiveView do
Returns an updated `socket`.
By default, the item is appended to the parent DOM container.
The `:at` option may be provided to insert or update an item
to a particular index in the collection on the client.
The `:at` option may be provided to insert an item at a particular index in
the collection on the client. If the item already exists in the parent DOM
container then it will be updated in place.
See `stream/4` for inserting multiple items at once.
Expand All @@ -1754,7 +1755,7 @@ defmodule Phoenix.LiveView do
stream_insert(socket, :songs, %Song{id: 2, title: "Song 2"}, at: 0)
Or updating an existing song, while also moving it to the top of the collection:
Or updating an existing song (in this case the `:at` option has no effect):
stream_insert(socket, :songs, %Song{id: 1, title: "Song 1 updated"}, at: 0)
Expand Down

0 comments on commit 76cb858

Please sign in to comment.