SettingsManager API Reference
TheSettingsManager
class provides a type-safe interface for accessing and monitoring App settings. It automatically synchronizes with MentraOS Cloud and provides real-time change notifications.
Import
Class: SettingsManager
Constructor
The SettingsManager is automatically instantiated by the AppSession. You should not create instances directly.Methods
get
Get a setting value.key
: Setting key to retrievedefaultValue
: Default value if setting doesn’t exist or is undefined
has
Check if a setting exists.key
: Setting key to check
getAll
Get all settings.getSetting
Find a setting by key and get the full setting object.key
: Setting key to find
onChange
Listen for changes to any setting.handler
: Function called when any setting changes
onValueChange
Listen for changes to a specific setting.key
: Setting key to monitorhandler
: Function called when the setting changes
fetch
Manually fetch settings from the cloud. This is generally not needed since settings are automatically kept in sync.MentraOS Settings
The SettingsManager also provides access to system-wide MentraOS settings.onMentraosSettingChange
Listen for changes to specific MentraOS settings.key
: MentraOS setting key (e.g., ‘metricSystemEnabled’)handler
: Function called when the value changes
getMentraosSetting
Get the current value of an MentraOS setting.key
: MentraOS setting keydefaultValue
: Default value if setting doesn’t exist
Best Practices
1. Provide Defaults
2. Type Your Settings
3. Clean Up Listeners
Related Documentation
- Settings Overview - Guide to using settings in Apps
- Setting Types Reference - Detailed type definitions
- App Session - AppSession class reference