What is your preference for storing hard coded data?

Hi friends, I have some hard-coded settings that I need to create a form with it, but it is so long in some page.
I want to ask what is your preference for keeping it. You import from a Jason file, or you are comfortable with dirty module like this code.

As you see, I have a long list for each tuple which I need to have them in runtime

Thank you in advance

We basically use an Agent to read yaml config files, then have an api like…


For our use case, I can’t see the Agent becoming a bottleneck.

That said, I wish there was some mechanism to recompile files if some other dependent file changed.

Something like…

defmodule MyConfig do
  recompile_if_changed "priv/config.json"

  |> set_module_attributes_and_accessor_functions()
1 Like

There is, it is called @external_resource. If you are reading a static configuration, there is never a need to use any runtime constructs, when you can inject the configuration into the module directly.


Every day I love this language more and more… the community too. Wow, this is a game changer for me! Thank you.

1 Like

And, remember to use __mix_recompile__?/0 :wink: