@splitsoftware/splitio-react-native
Version:
Split SDK for React Native
16 lines (14 loc) • 691 B
JavaScript
import reactNative from 'react-native';
let _RNEventSource;
// Try-catch to avoid Jest error `Invariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules`
try {
if (reactNative.NativeModules && reactNative.NativeModules.RNEventSource) _RNEventSource = require('./EventSource/EventSource');
} catch (e) {}
/**
* Returns native implementation of EventSource. If not available (e.g., Expo or other runtime than Android and iOS),
* checks if global EventSource is available and returns it.
*/
export function getEventSource() {
return _RNEventSource || (typeof EventSource === 'function' ? EventSource : undefined);
}
//# sourceMappingURL=getEventSource.js.map