MUSTDOS

MUSTDOS

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

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.

kevinschweikert

kevinschweikert

all good! i’ve cleaned up the previous posts

Where Next? Top

Trending in Proposals: Ideas Top

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews