deadego
How to delete a specific stream from a socket?
Trying to drop a specific stream from a socket in LV via.
{_, socket} =
pop_in(socket.assigns.streams[filter_string])
{_, socket} =
pop_in(socket.assigns.streams.__configured__[filter_string])
{:noreply, socket}
But get
[error] GenServer #PID<0.1919.0> terminating
** (KeyError) key "test" not found in: %{__changed__: MapSet.new([]), __configured__: %{}, __ref__: 1}
:erlang.map_get("test", %{__changed__: MapSet.new([]), __configured__: %{}, __ref__: 1})
(elixir 1.18.3) lib/map.ex:318: Map.update!/3
(phoenix_live_view 1.0.9) lib/phoenix_component.ex:1447: Phoenix.Component.update/3
(phoenix_live_view 1.0.9) lib/phoenix_live_view/lifecycle.ex:223: anonymous fn/2 in Phoenix.LiveView.Lifecycle.after_render/1
(phoenix_live_view 1.0.9) lib/phoenix_live_view/lifecycle.ex:237: Phoenix.LiveView.Lifecycle.reduce_socket/3
(phoenix_live_view 1.0.9) lib/phoenix_live_view/lifecycle.ex:222: Phoenix.LiveView.Lifecycle.after_render/1
(phoenix_live_view 1.0.9) lib/phoenix_live_view/channel.ex:992: anonymous fn/4 in Phoenix.LiveView.Channel.render_diff/3
(telemetry 1.3.0) /home/dead/Dev/gale/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
(phoenix_live_view 1.0.9) lib/phoenix_live_view/channel.ex:983: Phoenix.LiveView.Channel.render_diff/3
(phoenix_live_view 1.0.9) lib/phoenix_live_view/channel.ex:819: Phoenix.LiveView.Channel.handle_changed/4
(stdlib 6.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-GDKJG9wvY7sfv3iB", event: "event", payload: %{"event" => "delete_filter", "type" => "click", "value" => %{"filter" => "test"}}, ref: "17", join_ref: "4"}
State: %{socket: #Phoenix.LiveView.Socket<id: "phx-GDKJG9wvY7sfv3iB", endpoint: GaleWeb.Endpoint, view: GaleWeb.HomePageLive, parent_pid: nil, root_pid: #PID<0.1919.0>, router: GaleWeb.Router, assigns: %{filters: ["test"], __changed__: %{}, current_user: #Gale.Users.User<__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "f08b5683-2009-4b58-8a09-105e2fddb5d0", email: "asdf@asdf.com", confirmed_at: nil, inserted_at: ~U[2025-04-01 01:47:38Z], updated_at: ~U[2025-04-01 01:47:38Z], ...>, flash: %{}, filter_form: %Phoenix.HTML.Form{source: #Ecto.Changeset<action: nil, changes: %{}, errors: [], data: %{}, valid?: true, ...>, impl: Phoenix.HTML.FormData.Ecto.Changeset, id: "form", name: "form", data: %{}, action: nil, hidden: [], params: %{}, errors: [], options: [method: "post"], index: nil}, streams: %{:__changed__ => MapSet.new([]), :__configured__ => %{"test" => [dom_id: #Function<0.13511000/1 in GaleWeb.HomePageLive.handle_event/3>]}, :__ref__ => 1, "test" => %Phoenix.LiveView.LiveStream{name: "test", dom_id: #Function<0.13511000/1 in GaleWeb.HomePageLive.handle_event/3>, ref: "0", inserts: [], deletes: [], reset?: false, consumable?: false}}, live_action: :home}, transport_pid: #PID<0.1908.0>, ...>, components: {%{}, %{}, 1}, topic: "lv:phx-GDKJG9wvY7sfv3iB", serializer: Phoenix.Socket.V2.JSONSerializer, join_ref: "4", redirect_count: 0, upload_names: %{}, upload_pids: %{}}
[
I assume there is a better way?
Most Liked
kokolegorille
Maybe like this?
socket
|> stream(:mystream, [], reset: true)
But I don’t really understand what You are doing with your pop_in…
1
Popular in Questions
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
How to bind a phoenix app to a specific ip address?
could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Other popular topics
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New








