From 76cb858640d72c45e72dd1e0c432ff4d6b3bd244 Mon Sep 17 00:00:00 2001 From: Brian Alexander Date: Wed, 15 May 2024 04:01:11 -0600 Subject: [PATCH] Doc update for `Phoenix.LiveView.stream_insert/4` (#3198) * Update phoenix_live_view.ex * Update phoenix_live_view.ex * Update phoenix_live_view.ex --- lib/phoenix_live_view.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/phoenix_live_view.ex b/lib/phoenix_live_view.ex index 5a501fa6f..b67be2990 100644 --- a/lib/phoenix_live_view.ex +++ b/lib/phoenix_live_view.ex @@ -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. @@ -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)