Getting module attributes to recompile when config changes

I use module attributes frequently throughout my application for dependency injection and it works great. However, when I make a change in my config, which the module attribute often references, the value of the module attributes doesn’t update unless I make a code change in the module itself. This appears to be what forces the module to recompile and update the module attribute value.

Is there an easier way to do this?

If it is read from a file:


Thanks! I suppose I would use it like this?

def MyModule do
  @external_resource "config/config.exs"
  @api Application.get_env(:my_app, APi)

  def call_api do
1 Like

Maybe? I’m unsure if it is absolute or relative… ^.^;

1 Like

Here’s the answer to that: Relative path for @external_resource?

1 Like