SettingsSchemas Interface

The registry of metadata describing groups of SettingSchemas available to the current session. The schemas are used to look up the default values of Settings, validate that their values are of the type dictated by the schema, and query metadata like SettingsSchema.combineArray that modify their behavior. They can also be used to drive a user interface that enables end users to edit Settings.

When startup is invoked at the beginning of a session, schemas delivered with the application - like those describing Workspaces - are automatically loaded. The application can manually register additional schemas using methods like addGroup, addFile, addDirectory, and addJson. When shutdown is invoked at the end of a session, all registered schemas are unregistered.

See the learning article for a detailed overiew and examples.

@see settingsSchemas to access the registry for the current session.

Methods

Name Description
addDirectory(dirName: string): void Invokes addFile for every json and json5 file in the specified directory.  
addFile(fileName: string): void Invokes addGroup for a json5 file containiner a SettingGroupSchema.  
addGroup(settingsGroup: SettingGroupSchema | SettingGroupSchema[]): void Register one or more SettingGroupSchemas.  
addJson(settingSchema: string): void Invokes addGroup for a SettingGroupSchema supplied as stringified json5.  
removeGroup(schemaPrefix: string): void Unregisters all settingDefs and typeDefs with the specified schemaPrefix.  
validateSetting<T>(value: T, settingName: string): T Ensure that the setting value supplied is valid according to its SettingSchema.  

Properties

Name Type Description
onSchemaChanged Readonly BeEvent<() => void> An event raised whenever schemas are added or removed.  
settingDefs Readonly ReadonlyMap<string, SettingSchema> The map of each individual registered SettingSchema defining a Setting, accessed by its fully-qualified name (including its schemaPrefix).  
typeDefs Readonly ReadonlyMap<string, SettingSchema> The map of each individual registered SettingSchema defining a type that can be extended by other SettingSchemas via extends,  

Defined in

Last Updated: 17 December, 2024