io.prefsAPIinterface
App Preferences API.
11 Methods
clearFor()⚓︎
(app: string) => Promise<void>
Removes the user preferences for a specified app.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| app⚓︎ | string | Name of the app whose user preferences to remove. |
get()⚓︎
(app?: string) => Promise<AppPreferences | undefined>
Retrieves the user preferences for the current app.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| app⚓︎ | string | x | Name of the app for which to retrieve the user preferences. |
getAll()⚓︎
() => Promise<{ all: AppPreferences[]; }>
Retrieves all preferences stored for the current user.
set()⚓︎
(data: Data, options?: { app: string }) => Promise<void>
Replaces the user preferences for the current app. All existing properties will be removed and replaced with the ones supplied in the data object.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| data⚓︎ | Data | Data to replace the existing user preferences. |
|
| options⚓︎ | { app: string } | x | Object with an |
setFor()⚓︎
(app: string, data: Data) => Promise<void>
Replaces the user preferences of a specified app. All existing properties will be removed and replaced with the ones supplied in the data object.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| app⚓︎ | string | Name of the app whose user preferences to replace. |
|
| data⚓︎ | Data | Data to replace the existing user preferences. |
subscribe()⚓︎
(callback: (prefs: AppPreferences) => void) => () => void
Subscribes for changes to the user preferences of the current app.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| callback⚓︎ | (prefs: AppPreferences) => void | Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences. |
subscribeFor()⚓︎
(app: string, callback: (prefs: AppPreferences) => void) => () => void
Subscribes for changes to the user preferences of a specified app.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| app⚓︎ | string | Name of the app to which to subscribe. |
|
| callback⚓︎ | (prefs: AppPreferences) => void | Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences. |
update()⚓︎
(data: Data, options?: { app: string }) => Promise<void>
Updates the preferences for the current app. The properties specified in the data object will be merged with the existing user preferences.
Other existing properties will remain intact, and non-existent ones will be added.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| data⚓︎ | Data | Data to be merged with the existing user preferences. |
|
| options⚓︎ | { app: string } | x | Object with an |
updateFor()⚓︎
(app: string, data: Data) => Promise<void>
Updates the preferences for a specified app. The properties specified in the data object will be merged with the existing user preferences.
Other existing properties will remain intact, and non-existent ones will be added.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| app⚓︎ | string | Name of the app whose user preferences to update. |
|
| data⚓︎ | Data | Data to be merged with the existing user preferences. |