Class: DefaultUserSettingManager<T>
A manager for user settings. Provides settings using their names as keys, publishes value change events on the event bus, and keeps setting values up to date when receiving change events across the bus.
Type parameters
Name | Type |
---|---|
T | extends UserSettingRecord |
Implements
Constructors
constructor
• new DefaultUserSettingManager<T
>(bus
, settingDefs
, keepLocal?
): DefaultUserSettingManager
<T
>
Constructor.
Type parameters
Name | Type |
---|---|
T | extends UserSettingRecord |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
bus | EventBus | undefined | The bus used by this manager to publish setting change events. |
settingDefs | readonly UserSettingDefinition <T [keyof T ]>[] | undefined | The setting definitions used to initialize this manager's settings. |
keepLocal | boolean | false | If present and true, values will be kept local to the instrument on which they're set. |
Returns
Defined in
src/sdk/settings/UserSetting.ts:191
Properties
bus
• Protected
Readonly
bus: EventBus
The bus used by this manager to publish setting change events.
Defined in
src/sdk/settings/UserSetting.ts:192
publisher
• Protected
Readonly
publisher: Publisher
<T
>
Defined in
src/sdk/settings/UserSetting.ts:177
settings
• Protected
Readonly
settings: Map
<string
, UserSettingManagerEntry
<T
[keyof T
]>>
Defined in
src/sdk/settings/UserSetting.ts:175
subscriber
• Protected
Readonly
subscriber: EventSubscriber
<T
>
Defined in
src/sdk/settings/UserSetting.ts:178
syncPublisher
• Protected
Readonly
syncPublisher: Publisher
<UserSettingManagerSyncEvents
>
Defined in
src/sdk/settings/UserSetting.ts:180
syncSubscriber
• Protected
Readonly
syncSubscriber: EventSubscriber
<UserSettingManagerSyncEvents
>
Defined in
src/sdk/settings/UserSetting.ts:181
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/UserSetting.ts:270
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/UserSetting.ts:260
mapTo
▸ mapTo<M
>(map
): MappedUserSettingManager
<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 UserSettingRecord |
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
MappedUserSettingManager
<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/UserSetting.ts:285
onSettingValueChanged
▸ onSettingValueChanged<K
>(entry
, value
): void
A callback which is called when one of this manager's settings has its value changed locally.
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type | Description |
---|---|---|
entry | UserSettingManagerEntry <T [K ]> | The entry for the setting that was changed. |
value | T [K ] | The new value of the setting. |
Returns
void
Defined in
src/sdk/settings/UserSetting.ts:294
onSettingValueSynced
▸ onSettingValueSynced<K
>(entry
, data
): void
A callback which is called when a setting changed event is received over the event bus.
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type | Description |
---|---|---|
entry | UserSettingManagerEntry <T [K ]> | The entry for the setting that was changed. |
data | UserSettingManagerSyncData <T [K ]> | The sync data. |
Returns
void
Defined in
src/sdk/settings/UserSetting.ts:304
syncSettingFromEvent
▸ syncSettingFromEvent<K
>(entry
, data
): void
Syncs a setting using data received from a sync event.
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type | Description |
---|---|---|
entry | UserSettingManagerEntry <T [K ]> | The entry for the setting to sync. |
data | UserSettingManagerSyncData <T [K ]> | The sync event data. |
Returns
void
Defined in
src/sdk/settings/UserSetting.ts:323
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/UserSetting.ts:255
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/UserSetting.ts:275