1

I want to add a few data into socket but wondering what the best way to do that would be.

Instead of doing a bunch of

socket = assign(socket, :channel_id, channel_id)

user1354934
  • 8,139
  • 15
  • 50
  • 80

1 Answers1

5

There is an alternative function assign/2 that allows assigning multiple values at once, by passing either map or keyword list:

assign(socket, name: "Elixir", logo: "")
assign(socket, %{name: "Elixir"})
Daniel
  • 2,320
  • 1
  • 14
  • 27