Reputation: 8851
I want to add a few data into socket but wondering what the best way to do that would be.
socket
Instead of doing a bunch of
socket = assign(socket, :channel_id, channel_id)
Upvotes: 2
Views: 1096
Reputation: 2554
There is an alternative function assign/2 that allows assigning multiple values at once, by passing either map or keyword list:
assign/2
assign(socket, name: "Elixir", logo: "💧") assign(socket, %{name: "Elixir"})
Upvotes: 8