๐ Find a dependency's modules and functions
Notes
At some point, you may want to find out a dependencyโs modules or functions. Thankfully, Elixir has good introspection so we can do that at runtime!
Suppose we want to learn more about this obscure dependency called LiveView. ๐
We can first get the list of all modules for one of our dependencies using
Erlangโs :application.get_key/2
.
iex> :application.get_key(:phoenix_live_view, :modules)
# => {:ok, list_of_modules}
We see that Phoenix.LiveView.JS
is one of those modules.
Now, say we want to find out Phoenix.LiveView.JS
โs functions. We can use
Module.__info__/1
:
iex> Phoenix.LiveView.JS.__info__(:functions)`
# => all the functions
Voilร !
Keep that in your back pocket for when you need it. ๐