Class: AliasedUserSettingManager<T>
An aliased user setting manager which can dynamically (re)define the settings from which its aliased settings are sourced.
Type parameters
Name | Type |
---|---|
T | extends UserSettingRecord |
Implements
Constructors
constructor
• new AliasedUserSettingManager<T
>(bus
, settingDefs
): AliasedUserSettingManager
<T
>
Constructor.
Type parameters
Name | Type |
---|---|
T | extends UserSettingRecord |
Parameters
Name | Type | Description |
---|---|---|
bus | EventBus | The bus used by this manager to publish setting change events. |
settingDefs | readonly UserSettingDefinition <T [keyof T & string ]>[] | The setting definitions used to initialize this manager's settings. The definitions should define the settings' aliased names. |
Returns
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:23
Methods
getAllSettings
▸ getAllSettings(): UserSetting
<UserSettingValue
>[]
Gets an array of all settings of this manager.
Returns
UserSetting
<UserSettingValue
>[]
an array of all settings of this manager.
Implementation of
UserSettingManager.getAllSettings
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:76
getSetting
▸ getSetting<K
>(name
): UserSetting
<NonNullable
<T
[K
]>>
Gets a setting from this manager.
Type parameters
Name | Type |
---|---|
K | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | K | The name of the setting to get. |
Returns
UserSetting
<NonNullable
<T
[K
]>>
The requested setting.
Throws
Error if no setting with the specified name exists.
Implementation of
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:54
mapTo
▸ mapTo<M
>(map
): UserSettingManager
<M
& T
>
Maps a subset of this manager's settings to ones with aliased names, and creates a new setting manager which supports accessing the settings using their aliases.
Type parameters
Name | Type |
---|---|
M | extends Record <any , UserSettingValue > |
Parameters
Name | Type | Description |
---|---|---|
map | UserSettingMap <M , T > | A map defining the aliases of a subset of this manager's settings, with aliased setting names as keys and original setting names as values. |
Returns
UserSettingManager
<M
& T
>
A new setting manager which supports accessing a subset of this manager's settings using aliased names.
Implementation of
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:81
tryGetSetting
▸ tryGetSetting<K
>(name
): undefined
| UserSetting
<NonNullable
<T
[K
]>>
Attempts to get a setting from this manager.
Type parameters
Name | Type |
---|---|
K | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | K | The name of the setting to get. |
Returns
undefined
| UserSetting
<NonNullable
<T
[K
]>>
The requested setting, or undefined
if no such setting exists.
Implementation of
UserSettingManager.tryGetSetting
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:49
useAliases
▸ useAliases<O
>(masterManager
, map
): void
Defines the mappings from this manager's aliased settings to their source settings. Once the mappings are defined, each aliased setting will take the value of its source setting, and setting the value of the aliased setting will also set the value of the source setting. If a source setting cannot be defined for an aliased setting, the aliased setting's value will be fixed to its default value and cannot be changed.
Type parameters
Name | Type |
---|---|
O | extends UserSettingRecord |
Parameters
Name | Type | Description |
---|---|---|
masterManager | UserSettingManager <O > | The manager hosting the settings from which this manager's aliased settings will be sourced. |
map | UserSettingMap <T , O > | The mappings for this manager's aliased settings, as a set of key-value pairs where the keys are the aliased setting names and the values are the source setting names. For any aliased setting whose name does not appear as a key in the mapping, its source setting is assumed to have the same name. |
Returns
void
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:40
whenSettingChanged
▸ whenSettingChanged<K
>(name
): Consumer
<NonNullable
<T
[K
]>>
Gets a consumer which notifies handlers when the value of a setting changes.
Type parameters
Name | Type |
---|---|
K | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | K | The name of a setting. |
Returns
Consumer
<NonNullable
<T
[K
]>>
a consumer which notifies handlers when the value of the setting changes.
Throws
Error if no setting with the specified name exists.
Implementation of
UserSettingManager.whenSettingChanged
Defined in
src/sdk/settings/AliasedUserSettingManager.ts:64