elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.84k stars 582 forks source link

Remove list guard in Plug.Conn.merge_assigns and merge_private #1152

Closed hissssst closed 1 year ago

hissssst commented 1 year ago

Just a more flexible solution

josevalim commented 1 year ago

Can you please provide examples of use cases?

hissssst commented 1 year ago

I don't know why this limitation exists in the first place, I haven't found anything about this in original PR or commit messages

Here's an example from my codebase

static_assigns = static_assigns()
dynamic_assigns = 
  categories_assigns
  |> Map.merge(item_assigns)
  |> Map.merge(brands_assigns)
  |> Map.merge(overrides)
  |> Enum.to_list() # This is unnecessary

conn
|> merge_assigns(static_assigns)
|> merge_assigns(dynamic_assigns)
whatyouhide commented 1 year ago

I'm ok with a generic enumerable, but the Enumerable.t/1 type is a recent addition to Elixir. You'll have to use Enumerable.t() here. 🙃

hissssst commented 1 year ago

@whatyouhide @josevalim ping

josevalim commented 1 year ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: