Skip to main content
The StatsigSpecsDataAdapter is the default SpecsDataAdapter used by a StatsigOnDeviceEvalClient instance. It handles fetching and caching values from Statsig’s servers. If required, you can create your own custom SpecsDataAdapter and provide it to the Statsig client via StatsigOptions.dataAdapter.

Overview

Synchronous Behavior (Cache)

When calling StatsigOnDeviceEvalClient.initializeSync, the StatsigSpecsDataAdapter will load values from Cache and provide them to the client. The client will also call refresh in the background via StatsigSpecsDataAdapter.getDataAsync, leading to values lagging until the next time initializeSync. In practice, this means that for the very first session, there will be no values, and not until the next session will the cache have values.

Asynchronous Behavior (Network)

When calling StatsigOnDeviceEvalClient.initializeAsync, the StatsigSpecsDataAdapter will load values from Cache and provide them to the client. The client will then block on a call to StatsigSpecsDataAdapter.getDataAsync, allowing the ability to await the latest values from Statsig. If you want the latest values, but do not want to await the asynchronous call, you may call initializeAsync and simply .catch the promise. Note that this could lead to values changing mid-session as newer values arrive from the network.

Advanced Usage

Getting the Data Adapter

You can access the data adapter from your Statsig on-device client instance: