-
Notifications
You must be signed in to change notification settings - Fork 35
/
isomorphic.ts
26 lines (21 loc) · 701 Bytes
/
isomorphic.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import AsyncStorage from "./utils/async-storage";
import {IFlagsmith} from "./types";
import core from './flagsmith-core'
// @ts-ignore
globalThis.FlagsmithEventSource = typeof EventSource !== 'undefined' ? EventSource : null;
import eventSource from 'reconnecting-eventsource'
const flagsmith: IFlagsmith = core({
AsyncStorage,
eventSource: typeof window !=='undefined'?eventSource : null
});
if (typeof window !== "undefined") {
// @ts-ignore
window.flagsmith = flagsmith;
}
export default flagsmith;
export const createFlagsmithInstance = (): IFlagsmith => {
return core({
AsyncStorage,
eventSource: typeof window !=='undefined'?eventSource : null
})
}