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
Rethinking phx-no-feedback
So, I won’t go into how phx-no-feedback works in detail, but the tl;dr is that it lets you conditionally add a...
New
Hi there :wave:,
I hope everyone is doing well…
Tl;Dr: Is there a use case to have Heroicons from an actual hex.pm package instead of G...
New
Hi,
I’m trying to use phoenix.js in my Qt QML project which has it’s own buildin JavaScript engine. Problem is that (what I googled so f...
New
Hello everyone!
Phoenix LiveView v0.18 introduced the special attributes :let, :for and :if. In addition to the :if special attribute, I...
New
Would there be interest to implement a link/1 that gives to option to operate on other events?
So I implemented a simple link/1 function...
New
Currently, there are ongoing discussions about enhancing Phoenix LiveView, particularly focusing on improving performance and user experi...
New
We are seeing a lot of warning logs like this:
navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Other popular topics
Hello, how can I check the Phoenix version ?
Thanks !
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I would like to know what is the best IDE for elixir development?
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Latest Phoenix Threads
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
- #forms
- #api
- #metaprogramming
- #hex
- #security









