mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* rox-react-native: Minor improvements, update documentation links * rox-react-native: remove internal, undocumented, removed in next release method * rox-react-native: Upgrade package version, fix freeze options (they were plain wrong) * rox-react-native: Fix return type, add readonly attributes * rox-react-native: adding a few missing items * rox-react-native: default value of a Flag is optional * rox-react-native: More extensive tests * rox-react-native: make fetcher result an enum * rox-react-native: Add missing AsyncStorage parameter to setup method
67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import * as Rox from 'rox-react-native';
|
|
|
|
const flags = {
|
|
superFlag: new Rox.Flag(false, { freeze: Rox.FreezeOptions.freezeOptionNone }),
|
|
superFlag2: new Rox.Flag(),
|
|
};
|
|
|
|
const variants = {
|
|
superVariant: new Rox.Variant('value1', ['value1', 'value2'])
|
|
};
|
|
|
|
const configurations = {
|
|
superConfiguration: new Rox.Configuration('☀️'),
|
|
superConfiguration2: new Rox.Configuration(true),
|
|
};
|
|
|
|
// The register function should be called before the call to Rox.setup()
|
|
Rox.register('default', { ...configurations, ...variants, ...flags });
|
|
Rox.setup('ROLLOUT_IO_KEY', {
|
|
impressionHandler,
|
|
configurationFetchedHandler,
|
|
}).then(linkTargetGroupAttributes);
|
|
|
|
Rox.dynamicApi.isEnabled('system.repotAnalytics', false);
|
|
Rox.dynamicApi.value('ui.textColor', 'red');
|
|
|
|
Rox.flags[0].defaultValue;
|
|
Rox.flags[0].name;
|
|
|
|
flags.superFlag.isEnabled();
|
|
|
|
configurations.superConfiguration.defaultValue;
|
|
configurations.superConfiguration.name;
|
|
configurations.superConfiguration.getValue();
|
|
|
|
variants.superVariant.defaultValue;
|
|
variants.superVariant.name;
|
|
variants.superVariant.getValue();
|
|
|
|
Rox.unfreeze();
|
|
flags.superFlag.unfreeze();
|
|
|
|
function linkTargetGroupAttributes() {
|
|
Rox.setCustomStringProperty('id', 'someId');
|
|
Rox.setCustomStringProperty('id', () => 'someId');
|
|
|
|
Rox.setCustomBooleanProperty('thisIsATest', true);
|
|
Rox.setCustomBooleanProperty('thisIsATest', () => true);
|
|
|
|
Rox.setCustomNumberProperty('aNumberProperty', 17);
|
|
Rox.setCustomNumberProperty('aNumberProperty', () => 17);
|
|
|
|
Rox.setDynamicCustomPropertyRule((propName: string, _context: unknown) => {
|
|
return propName === 'myPropName';
|
|
});
|
|
}
|
|
|
|
function impressionHandler(_reporting: Rox.RoxReporting, _experiment?: Rox.RoxExperiment) {
|
|
// If there is no experiment it means that the user has not been enrolled
|
|
// or that the reporting is not used yet
|
|
}
|
|
|
|
function configurationFetchedHandler(fetcherResult: Rox.RoxFetcherResult) {
|
|
if (fetcherResult.hasChanges && fetcherResult.fetcherStatus === Rox.RoxFetcherStatus.AppliedFromCache) {
|
|
}
|
|
}
|