Skip to content

ReactiveStore

ReactiveStore is an in-memory key-value store backed by the window object with Proxy-based validation. The library uses it internally to hold configuration and runtime state.

View as Markdown llms.txt

All methods are static:

import { ReactiveStore } from '@segmentify/integration';
ReactiveStore.set('myKey', 'myValue');
const value = ReactiveStore.get('myKey'); // 'myValue'
ReactiveStore.has('myKey'); // true
ReactiveStore.remove('myKey');
ReactiveStore.getAll(); // { ... }
ReactiveStore.clear();

set, remove, and clear return the class for chaining:

ReactiveStore.set('lang', 'EN').set('currency', 'USD');

Attach validation functions to keys. Invalid values throw an error:

ReactiveStore.addValidator(
'apiKey',
v => typeof v === 'string' && v.length > 0
);
ReactiveStore.set('apiKey', 'abc123'); // OK
ReactiveStore.set('apiKey', ''); // throws Error
KeyPurpose
__store:SegmentifyConfigThe SegmentifyConfig object
__store:SegmentifyPageThe pageMap configuration
__store:__segmentifyReady__true when SDK is loaded
__segmentify:initialized__Prevents double initialization

::: warning Avoid overwriting these keys — doing so may break the library. :::

FeatureReactiveStorePersistedStore
Storagewindow (memory)localStorage (persistent)
Survives page reloadNoYes
ValidatorsYesNo
Value typeAnyStrings only
Use caseRuntime stateUser data, event queues