# PreferencesAPI

**Kind**: interface | **Module**: [Platform](https://docs.interop.io/desktop/reference/javascript/platform/index.md) | **Access**: `io.platform.prefs`

**Source**: https://docs.interop.io/desktop/reference/javascript/platform/preferencesapi/index.html

Provides methods for retrieving, updating, and resetting platform preferences, as well as for subscribing to preference changes.

*Since: io.Connect Desktop 10.6, @interopio/desktop 6.24.0*

## Methods

### get

Retrieves an object describing the platform preferences.

```ts
<T extends Record<string, unknown> = Record<string, unknown>>() => Promise<PlatformPreferences<T>>
```

**Returns**: `Promise<PlatformPreferences<T>>`

### reset

Removes user overrides for the specified settings. Settings without user overrides will use administrator defaults or defaults provided by the platform.
Locked settings will remain unchanged.

>  *Note that on **io.Connect Desktop** versions earlier than 10.6, this method isn'supported*

```ts
(paths: string[]) => Promise<void>
```

**Parameters**

- **`paths`** (`string[]`, required)
  Array of strings representing paths to the preferences to reset. Use dot notation (e.g., `"downloadManager.autoSave"`).

**Returns**: `Promise<void>`

### subscribe

Subscribes for changes to the platform preferences. Returns an unsubscribe function.

```ts
<T extends Record<string, unknown> = Record<string, unknown>>(callback: (snapshot: PlatformPreferences<T>) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(snapshot: PlatformPreferences<T>) => void`, required)
  Callback function that will be invoked with the current platform preferences and after that on each update.
  The callback may also be invoked with unchanged preferences when another subscription is registered in the same window.

**Returns**: `UnsubscribeFunction`

### update

Updates the user preferences for the platform. Nested objects in `changes` will be merged with the existing objects,
and arrays will replace the existing arrays.
Locked settings, invalid values, or schedule settings supplied in `changes` will be ignored and listed in the `ignored` property of the result.

>  *Note that on **io.Connect Desktop** versions earlier than 10.6, preferences are merged in the client, which means:*
> - Concurrent updates to the same property at the root of the preferences object may overwrite each other.
> - Download and notification settings will be applied after restarting the platform.
> - Schedule settings will be stored but won't schedule platform restart or shutdown.

```ts
(changes: Record<string, unknown>) => Promise<PreferencesUpdateResult>
```

**Parameters**

- **`changes`** (`Record<string, unknown>`, required)
  Preferences to merge with the existing user preferences.

**Returns**: `Promise<PreferencesUpdateResult>`

## Related types

- [PlatformPreferences](https://docs.interop.io/desktop/reference/javascript/platform/platformpreferences/index.md)
- [PreferencesUpdateResult](https://docs.interop.io/desktop/reference/javascript/platform/preferencesupdateresult/index.md)
- [UnsubscribeFunction](https://docs.interop.io/desktop/reference/javascript/search/unsubscribefunction/index.md)
