UNPKG

@harnessio/ff-react-native-client-sdk

Version:

[![React version][react-badge]][reactjs] [![React Native version][react-native-badge]][reactnative] [![TypeScript version][ts-badge]][typescript-4-7] [![Node.js version][nodejs-badge]][nodejs] [![APLv2][license-badge]][license]

37 lines (36 loc) 1.1 kB
import AsyncStorage from '@react-native-async-storage/async-storage'; import { Platform } from 'react-native'; export function processOptions(options) { return { ...processStreamingOptions(options), cache: processCacheOptions(options?.cache) }; } function processStreamingOptions(options) { if ((typeof options?.streamEnabled === 'undefined' || options.streamEnabled) && Platform.OS === 'android') { const logger = options?.logger?.info ? options.logger : console; logger.info('SDKCODE:1007 Android React Native detected - streaming will be disabled and polling enabled'); return { ...options, streamEnabled: false, pollingEnabled: options?.pollingEnabled !== false }; } return options; } function processCacheOptions(cache) { if (!cache) return false; if (typeof cache === 'boolean') { return { storage: AsyncStorage }; } if (!cache.storage) { return { ...cache, storage: AsyncStorage }; } }