Home > @uniformdev/context > TransitionDataStore

TransitionDataStore class

Signature:

Constructors

Constructor

Modifiers

Description

(constructor)({ initialData }, input)

Constructs a new instance of the TransitionDataStore class

Properties

Property

Modifiers

Type

Description

data

readonly

Partial<VisitorData> | undefined

events

readonly

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

Subscribe to events from the transition storage

initialData

readonly

Partial<VisitorData> | undefined

Methods

Method

Modifiers

Description

delete(fromAllDevices)

Deletes a visitor's stored data, forgetting them.

getClientTransitionState()

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.

handleDelete(fromAllDevices)

abstract

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

handleUpdateData(commands, computedValue)

abstract

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.

signalAsyncDataUpdate(newScores)

protected

updateData(commands, computedValue)

Updates data in the transition storage.