packageDocumentation module import { UiStateStorage , UiStateStorageResult , UiStateStorageStatus } from "./UiStateStorage" ; public export class UiStateEntry < T > { param settingNamespace param settingName param getValue param applyValue param defaultValue public constructor ( public settingNamespace , public settingName , public getValue , public applyValue ? , public defaultValue ? ) { } /** Gets the setting from [[UiStateStorage]] */ public async getSetting ( storage ) { return storage . getSetting ( this . settingNamespace , this . settingName ) ; } /** Saves the setting value from the `getValue` function to UiStateStorage */ public async saveSetting ( storage ) { return storage . saveSetting ( this . settingNamespace , this . settingName , this . getValue ( ) ) ; } /** Deletes the setting from UiStateStorage */ public async deleteSetting ( storage ) { return storage . deleteSetting ( this . settingNamespace , this . settingName ) ; } /** Gets the setting from UiStateStorage and applies the value using the `applyValue` function */ public async getSettingAndApplyValue ( storage ) { if ( this . applyValue ) { const result = await this . getSetting ( storage ) ; if ( result . status === UiStateStorageStatus . Success ) { this . applyValue ( result . setting ) ; } else if ( undefined !== this . defaultValue ) { this . applyValue ( this . defaultValue ) ; result . setting = this . defaultValue ; result . status = UiStateStorageStatus . Success ; } return result ; } return { status : UiStateStorageStatus . Uninitialized } ; } }