Remove assigns in LiveView

Hi!

Is there an opposite of assign(socket ...) ?

i’m looking to remove an assigns from the socket, but the only solution i’m seeing is setting the assigns value to nil

I tried this, but it didn’t work for me:

2 Likes

Hello,
assigns is a Map, so it should work

%{
  socket 
  | assigns: Map.delete(socket.assigns, :key), 
    changed: Map.put_new(socket.changed, :key, true)
}
4 Likes

Ah, I missed the changed part. Thanks!!

Seems that as of now (Dec 2022), the :changed key is no longer in the socket struct, and is no longer necessary?