# provideSiUiState Type documentation

## TypeScript declaration

### [provideSiUiState](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L134-L139>)

**Kind:** constant

```
import { provideSiUiState } from '@siemens/element-ng/common';
```

Enables the automatic storage of UI state for enabled components.

```
(config?: { store?: Type<UIStateStorage> | undefined; } | undefined) => Provider[] = ...
```

```
provideSiUiState(config?: { store?: Type<UIStateStorage>; }): Provider[]
```

Enables the automatic storage of UI state for enabled components.

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [config](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L134-L134>) (optional) | `{ store?: Type<UIStateStorage>; }` |  |  |

**Returns:** [Provider](<https://angular.dev/api/core/Provider>)`[]`

### Types Documentation

### [UIStateStorage](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L22-L44>)

**Kind:** interface

```
import type { UIStateStorage } from '@siemens/element-ng/common';
```

Interface that defines a UIStateStore. It must be provided via [provideSiUiState](<index.html#t:provideSiUiState>).

```
interface UIStateStorage
```

#### Methods

##### load

[Source for load](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L43-L43>)

Loads data for a specific stateId. Can be asynchronous.

Errors should be handled by the implementation. The `SiUIStateService` does not handle errors.

Returns: The data or undefined if the data does not exist. Asynchronous implementations must return a [Promise](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise>) containing the data.

```
load(stateId: string): string | Promise<string | null | undefined> | null | undefined
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [stateId](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L43-L43>) | `string` |  |  |

**Returns:** [string](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String>)`  |  `[Promise](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise>)`<`[string](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String>)`  |  `[null](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/null>)`  |  `[undefined](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined>)`> | `[null](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/null>)`  |  `[undefined](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined>)

##### save

[Source for save](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L31-L31>)

Saves data under a specific stateId. Already existing data for that stateId should be overridden. Asynchronous implementations must return a [Promise](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise>) and resolve it once saving was completed.

Errors should be handled by the implementation. The `SiUIStateService` does not handle errors.

```
save(stateId: string, data: string): void | Promise<void>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [stateId](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L31-L31>) | `string` |  |  |
| [data](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/si-uistate.service.ts#L31-L31>) | `string` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)`  |  `[Promise](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise>)`<`[void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)`>`
