Exit IEx Gracefully with `respawn()`
I love a debugger in my Elixir code. A pattern I follow is to load and call IEx in a Phoenix template or controller with:
require IEx; IEx.pry;
Then, I call functions and check data in the middle of an action, by starting my Phoenix server with the following command:
$ iex -S mix phx.server
Once finished, I usually end up just killing the server with CTRL-C
.
Today I learned there's a better way: respawn()
.
respawn()
respawns the current shell by starting a new shell process. Which I think is a good thing. It lets me back out of my IEx session without killing my server, a much more graceful development experience.