Raxol.Core.UserPreferences (Raxol v0.3.0)
View SourceManages user preferences for the Raxol application.
Acts as a GenServer holding the preferences state and handles persistence.
Summary
Functions
Returns a specification to start this module under a supervisor.
Gets a user preference value by key path.
Retrieves the entire preferences map. Accepts an optional PID or registered name
Forces an immediate save of the current preferences.
Sets a user preference value by key path.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Gets a user preference value by key path.
Accepts a single key or a list of keys for nested access.
Examples
UserPreferences.get(:theme) #=> "dark"
UserPreferences.get([:accessibility, :high_contrast]) #=> true
UserPreferences.get(:theme, my_prefs_pid) #=> "dark"
Retrieves the entire preferences map. Accepts an optional PID or registered name
Examples
UserPreferences.get_all()
UserPreferences.get_all(my_prefs_pid)
Forces an immediate save of the current preferences.
@spec set(atom() | [atom()], any(), GenServer.server() | atom() | nil) :: :ok
Sets a user preference value by key path.
Accepts a single key or a list of keys for nested access. Triggers an automatic save after a short delay.
Examples
UserPreferences.set(:theme, "light")
UserPreferences.set([:accessibility, :high_contrast], false)
UserPreferences.set(:theme, "light", my_prefs_pid)