While debugging and experimenting with apis in javascript, I usually set a variable
on window
and then play with it in the console.
1 |
|
Once the above code is set, I can just jump into the console and start pushing messages to the channel and discover how it all works by poking it around.
This led me to think about how this can be done in Elixir. And, in one of my
recent projects, I was spawning a few processes and wanted to get their pids
to play around by sending messages to them. And I just thought why not use ets
as global bucket to shove stuff into. Here is my solution:
Just create an ets
table in your .iex.exs
1 | # .iex.exs |
And, wherever you want, just push things into this table:
1 | # in my app |
Once you have that, you can start poking and prodding your processes/variables
1 | # iex> |
Hope this helps you while debugging your Elixir apps :D