Skip to main content

Class: SessionStorage<V>

@ima/core.SessionStorage

Implementation of the link Storage interface that relies on the native sessionStorage DOM storage for storing its entries.

Type parameters

Name
V

Hierarchy

Constructors

constructor

new SessionStorage<V>(window)

Initializes the session storage.

Type parameters

Name
V

Parameters

NameType
windowClientWindow

Overrides

Storage.constructor

Defined in

packages/core/src/storage/SessionStorage.ts:24

Properties

_storage

Private _storage: Storage

The DOM storage providing the actual storage of the entries.

Defined in

packages/core/src/storage/SessionStorage.ts:15

Accessors

$dependencies

Static get $dependencies(): Dependencies

Returns

Dependencies

Defined in

packages/core/src/storage/SessionStorage.ts:17

Methods

_deleteOldestEntry

_deleteOldestEntry(): void

Deletes the oldest entry in this storage.

Returns

void

Defined in

packages/core/src/storage/SessionStorage.ts:123


clear

clear(): SessionStorage<V>

Clears the storage of all entries.

Returns

SessionStorage<V>

This storage.

Overrides

Storage.clear

Defined in

packages/core/src/storage/SessionStorage.ts:100


delete

delete(key): SessionStorage<V>

Deletes the entry identified by the specified key from this storage.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

SessionStorage<V>

This storage.

Overrides

Storage.delete

Defined in

packages/core/src/storage/SessionStorage.ts:91


get

get(key): undefined | V

Retrieves the value of the entry identified by the specified . The method returns undefined if the entry does not exists.

Entries set to the undefined value can be tested for existence using the link has method.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

undefined | V

The value of the storage entry.

Overrides

Storage.get

Defined in

packages/core/src/storage/SessionStorage.ts:47


has

has(key): boolean

Returns true if the entry identified by the specified key exists in this storage.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

boolean

true if the storage entry exists.

Overrides

Storage.has

Defined in

packages/core/src/storage/SessionStorage.ts:40


init

init(): SessionStorage<V>

This method is used to finalize the initialization of the storage after the dependencies provided through the constructor have been prepared for use.

This method must be invoked only once and it must be the first method invoked on this instance.

Returns

SessionStorage<V>

This storage.

Overrides

Storage.init

Defined in

packages/core/src/storage/SessionStorage.ts:33


keys

keys(): Iterable<string>

Returns an iterator for traversing the keys in this storage. The order in which the keys are traversed is undefined.

Returns

Iterable<string>

An iterator for traversing the keys in this storage. The iterator also implements the iterable protocol, returning itself as its own iterator, allowing it to be used in a for..of loop.

Overrides

Storage.keys

Defined in

packages/core/src/storage/SessionStorage.ts:109


set

set(key, value): SessionStorage<V>

Sets the storage entry identified by the specified key to the provided value. The method creates the entry if it does not exist already.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.
valueVThe storage entry value.

Returns

SessionStorage<V>

This storage.

Overrides

Storage.set

Defined in

packages/core/src/storage/SessionStorage.ts:62


size

size(): number

Returns the number of entries in this storage.

Returns

number

The number of entries in this storage.

Overrides

Storage.size

Defined in

packages/core/src/storage/SessionStorage.ts:116