Skip to content

Commit

Permalink
merge stream config into opts
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Jan 23, 2024
1 parent ce4b303 commit d4bc58a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/phoenix_live_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,8 @@ defmodule Phoenix.LiveView do
Enum.reduce(items, new_socket, fn item, acc -> stream_insert(acc, name, item, opts) end)

%{} ->
config = get_in(streams, [:__configured__, name]) || opts
config = get_in(streams, [:__configured__, name]) || []
opts = Keyword.merge(opts, config)

ref =
if cid = socket.assigns[:myself] do
Expand All @@ -1829,7 +1830,7 @@ defmodule Phoenix.LiveView do
to_string(streams.__ref__)
end

stream = LiveStream.new(name, ref, items, config)
stream = LiveStream.new(name, ref, items, opts)

socket
|> Phoenix.Component.update(:streams, fn streams ->
Expand Down
2 changes: 2 additions & 0 deletions test/support/live_views/streams.ex
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ defmodule Phoenix.LiveViewTest.StreamLimitLive do
# see https://github.com/phoenixframework/phoenix_live_view/issues/2686

def mount(_params, _session, socket) do
socket = stream_configure(socket, :items, [])

{:noreply, socket} = handle_event("configure", %{"at" => "-1", "limit" => "-5"}, socket)
{:ok, socket}
end
Expand Down

0 comments on commit d4bc58a

Please sign in to comment.