๐Ÿ” 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. ๐Ÿ˜‰

Want the latest Elixir Streams in your inbox?

    No spam. Unsubscribe any time.