# Interface ApplicationState<StateT>

ApplicationState allows an application to recover its state StateT from before the Twinfinity session was established.

interface ApplicationState<StateT> {
deserialize(serializedState: string): StateT;
getCurrentState(): Promise<StateT>;
serialize(state: StateT): string;
}

#### Type Parameters

- StateT

##### Index

### Methods

deserialize
getCurrentState
serialize

## Methods

### deserialize

- deserialize(serializedState: string): StateT

  A function that is able to deserialize the serialized value output by serialize into a StateT

  #### Parameters

  - serializedState: string

  #### Returns StateT

### getCurrentState

- getCurrentState(): Promise<StateT>

  Should return the current value of StateT. This method is called by TwinfinitySession.establish and TwinfinitySession.reEstablish before the browser redirected to the Open ID connect provider. The same value is then restored after TwinfinitySession has been successfully established.

  #### Returns Promise<StateT>

### serialize

- serialize(state: StateT): string

  A function that serializes StateT to a string such that it can be deserialized by deserialize

  #### Parameters

  - state: StateT

  #### Returns string