Skip to content

inbetgames/sweetconfig

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sweetconfig

Build Status

Place configuration YAML files in priv/ directory of your root application. Add following section to your config.exs file:

config :sweetconfig,
	app: :name_of_your_application

Include :sweetconfig into your app deps list.

Now you can read configuration at any point in your app like this:

Sweetconfig.get :somekey
Sweetconfig.get [:somekey, :somesubkey]
Sweetconfig.get :whatever, :default_value

Subscribing to changes

It is possible to get notifications when a certain config value has changed during config reload.

path = [:root, :some, "nested", "value"]
Sweetconfig.subscribe path, self()
Sweetconfig.Utils.load_configs  # assume this changes the value at the path above
receive do
  {Sweetconfig.Pubsub, ^path, {:changed, old, new}} ->
    IO.inspect old
    IO.inspect new
end

About

something to forget about configuration in releases

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Elixir 100.0%