@optimizely/js-sdk-datafile-manager
v0.9.5
Published
Optimizely Full Stack Datafile Manager
Downloads
378,601
Readme
Javascript SDK Datafile Manager
This package provides datafile manager implementations for Node.js, browsers, and React Native.
Requirements
In general, an ES5-compatible environment is required, as well as Promise (must be polyfilled if absent).
Platform-specific minimum supported versions:
- Node.js:
8 - React Native:
0.61.5
Installation
npm i @optimizely/js-sdk-datafile-managerFor React Native, installation of peer dependency @react-native-async-storage/async-storage is also required:
npm i @react-native-async-storage/async-storageUsage
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager')
const manager = new HttpPollingDatafileManager({
sdkKey: '9LCprAQyd1bs1BBXZ3nVji',
autoUpdate: true,
updateInterval: 5000,
})
manager.start()
manager.onReady().then(() => {
const datafile = manager.get()
console.log('Manager is ready with datafile: ')
console.log(datafile)
})
manager.on('update', ({ datafile }) => {
console.log('New datafile available: ')
console.log(datafile)
})Development
- The
lintpackage.json script runs ESLint and Prettier. This applies formatting and lint fixes to all.tsfiles in thesrc/directory. - The
testpackage.json script runs our Jest-based test suite. - The
tscpackage.json script runs the TypeScript compiler to build the final scripts for publishing (into thelib/directory).
