Home > @uniformdev/context > TransitionDataStore

TransitionDataStore class

Signature:

Constructors

<table><thead><tr><th>

Constructor

</th><th>

Modifiers

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

(constructor)({ initialData })

</td><td>

</td><td>

Constructs a new instance of the TransitionDataStore class

</td></tr> </tbody></table>

Properties

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

data

</td><td>

readonly

</td><td>

Partial<VisitorData> | undefined

</td><td>

</td></tr> <tr><td>

events

</td><td>

readonly

</td><td>

{ on: { <Key extends "dataUpdatedAsync">(type: Key, handler: mitt.Handler<TransitionDataStoreEvents>): void; }; }

</td><td>

Subscribe to events from the transition storage

</td></tr> <tr><td>

initialData

</td><td>

readonly

</td><td>

Partial<VisitorData> | undefined

</td><td>

</td></tr> </tbody></table>

Methods

<table><thead><tr><th>

Method

</th><th>

Modifiers

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

delete(fromAllDevices)

</td><td>

</td><td>

Deletes a visitor's stored data, forgetting them.

</td></tr> <tr><td>

getClientTransitionState()

</td><td>

</td><td>

When we load on the client side after a server side rendering has occurred (server to client transition), we can have a page script (ID: __UNIFORM_DATA__) that contains the computed visitor data from the SSR/edge render. This data is injected into the first render to allow score syncing and the server to request commands be applied to the client side data store.

</td></tr> <tr><td>

handleDelete(fromAllDevices)

</td><td>

abstract

</td><td>

Deletes a visitor's stored data, forgetting them. Important: do not emit any async score update events from this function.

</td></tr> <tr><td>

handleUpdateData(commands, computedValue)

</td><td>

abstract

</td><td>

Updates visitor data in the transition store.

NOTE: The updated data is optimistically stored in TransitionDataStore automatically, so unless the updated data is _changed_ by the backend data store, there is no need to emit async score changed events when the visitor data is done updating.

</td></tr> <tr><td>

signalAsyncDataUpdate(newScores)

</td><td>

protected

</td><td>

</td></tr> <tr><td>

updateData(commands, computedValue)

</td><td>

</td><td>

Updates data in the transition storage.

</td></tr> </tbody></table>