MUSTDOS
Multi assign/stream
Hello all!
assign(socket, :name, “Elixir”)
Why can’t we have assign/stream take a group of atoms and maps/structs as a default to reduce spamming assign/stream along with their parentheses?
I know this isn’t a perfect example of code but here’s what I cooked up but it returns a list of assigns/streams instead finalizing them
def socket_initializer(socket,initializer_list) do
socket = Enum.map(initializer_list, fn {key,value} ->
case key do
:stream ->
Enum.map(value, fn {stream_name, stream_value} ->
IO.inspect stream(socket, stream_name, stream_value)
end)
:assign ->
Enum.map(value, fn {assign_name, assign_value} ->
IO.inspect assign(socket, assign_name, assign_value)
end)
_ ->
IO.puts(to_string(key) <> " is not a valid initalizer")
end
end)
end
initializer_list = [
{ :assign , [ {:search, %Worker{}}, {:active_account_tuple , Operations.status_tuple_registration()} ] },
{ :stream , [ {:workers , %Worker{}} ] }
]
Most Liked
rhcarvalho
stream/4 works on a single stream, but assign/2 can assign multiple values at once.
The one you were referring to is assign/3 which works on a single item.
2
kevinschweikert
Popular in Proposals: Ideas
I have been using a multi-endpoint setup in my app, just because I think it makes the most sense for a multi-subdomain app. This worked w...
New
IEx is a very powerfull shell and it would be awesome to have all this power integrated inside a code editor. Clojure enables something l...
New
Hi!
I would like to suggest a new callback in the lifecycle of the Live Component which is unmount.
Sometimes it is nice to be able to ...
New
Hi,
Oficial docs got this wonderful feature to download the ePub version that we can chuck to our kindles and read it. Now we are in the...
New
Each time i use phx.gen I end up adding dark mode to it.
I’m offering to add this to the default phx gen templates.
This would
use ta...
New
Hi Phoenix community!
First off, huge thanks for an amazing framework - Phoenix has been a joy to work with. I have a small UX suggestio...
New
Good morning to the Elixir team.
Please excuse me if I’m commenting in the wrong place; please indicate where I should discuss this.
I ...
New
Other popular topics
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
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 set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










