Usage of IEx.after_spawn/1?

Hi,

I came across a function IEx.after_spawn. After reading the docs I thought it would be a useful function to show a welcome message when someone starts IEx within a specific project.

So I’ve put this in the root of the project in .iex.exs:

IEx.after_spawn &H.motd/0
 defmodule H do
   def motd do
     IO.puts """
     _ _ _       _
     | | | | ___ | | ___  ___  _____  ___
     | | | || -_|| ||  _|| . ||     || -_|
     |_____||___||_||___||___||_|_|_||___|
     """
   end
 end

However, I see no output when starting IEx. It does seem registered, calling IEx.after_spawn does yield a list with this function, calling this function directly also yields the expected output. So my question: am I doing something wrong or is this callback not useful for my purposes?

1 Like