-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.ts
21 lines (18 loc) · 757 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { IFlagsmith } from './types';
// @ts-ignore
globalThis.FlagsmithEventSource = typeof EventSource!== "undefined"? EventSource: null;
import fetch from "unfetch"
import AsyncStorage from "./utils/async-storage";
import core, { LikeFetch } from './flagsmith-core';
import _EventSource from 'reconnecting-eventsource'
// @ts-expect-error
const _fetch = fetch as LikeFetch
const flagsmith = core({AsyncStorage, fetch:_fetch, eventSource:_EventSource});
if (typeof window !== "undefined") {
// @ts-expect-error, some people wish to use flagsmith globally
window.flagsmith = flagsmith;
}
export default flagsmith;
export const createFlagsmithInstance = ():IFlagsmith=>{
return core({ AsyncStorage, fetch:_fetch, eventSource:_EventSource})
}