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.
All methods are static:
import { ReactiveStore } from '@segmentify/integration';
ReactiveStore.set('myKey', 'myValue');const value = ReactiveStore.get('myKey'); // 'myValue'ReactiveStore.has('myKey'); // trueReactiveStore.remove('myKey');ReactiveStore.getAll(); // { ... }ReactiveStore.clear();set, remove, and clear return the class for chaining:
ReactiveStore.set('lang', 'EN').set('currency', 'USD');Validators
Section titled “Validators”Attach validation functions to keys. Invalid values throw an error:
ReactiveStore.addValidator( 'apiKey', v => typeof v === 'string' && v.length > 0);
ReactiveStore.set('apiKey', 'abc123'); // OKReactiveStore.set('apiKey', ''); // throws ErrorInternal Keys
Section titled “Internal Keys”| Key | Purpose |
|---|---|
__store:SegmentifyConfig | The SegmentifyConfig object |
__store:SegmentifyPage | The 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. :::
ReactiveStore vs PersistedStore
Section titled “ReactiveStore vs PersistedStore”| Feature | ReactiveStore | PersistedStore |
|---|---|---|
| Storage | window (memory) | localStorage (persistent) |
| Survives page reload | No | Yes |
| Validators | Yes | No |
| Value type | Any | Strings only |
| Use case | Runtime state | User data, event queues |