import {getGlobalConfig, setGlobalConfig} from '../../global'; const {cloneDeep} = require('lodash') interface IPdConfig { pdServiceKey: string } const trimKey = (value: any): string => typeof value === 'string' ? value.trim() : ''; let obj: IPdConfig | null = null; /** * Setting up config in the singleation, use this function on your application init * @sync * @stable * @param pdServiceKey */ export const setPdConfig = (pdServiceKey: string) => { obj = { pdServiceKey: trimKey(pdServiceKey) } setGlobalConfig(obj, 'pdConfig') console.log(obj) } /** * Used to get config from the singleation, mostly used internally * @sync * @stable * @internal */ export const getPdConfig = ():IPdConfig => { return cloneDeep(getGlobalConfig('pdConfig')) || { pdServiceKey: '' } }