Create a new OptionContext instance.
Array of all available options to manage
Get all available options
Get current state of all options
Add a listener for state changes. Called whenever any option state is updated.
Callback function to invoke on state changes
Remove a state change listener.
Callback function to remove
Add a listener for value changes. Called whenever a specific option value is updated.
Callback function receiving (key, value) on changes
Remove a value change listener.
Callback function to remove
Increment the availability counter for an option. Used to track how many components are using this option.
The option key to increment availability for
Decrement the availability counter for an option. Used when a component stops using this option.
The option key to decrement availability for
Get the current state for a specific option.
The option key to get state for
OptionState or null if option doesn't exist
Get the current value for a specific option. Returns the set value, or the default value if no value is set.
The option key to get value for
Current value, default value, or null
Set the value for a specific option. Triggers value change listeners and state change notification.
The option key to set value for
The value to set
Set multiple option values at once. Useful for bulk updates or initialization.
Object mapping option keys to values
Set the default value for an option. Used when no explicit value is set.
The option key to set default for
The default value to use
Set the available option values for a specific option key. Used by Selector components to register their available options.
The option key to set available options for
Array of available option values
OptionContext manages the state of all avatar customization options.
This class provides:
Example