I have following code which doesn't work due to syntax error (await outside an async function)
how do I define a variable with await and export it?
When I define a variable like this and import it from other files, does the variable gets created only once (when file is first read?) or gets created everytime when it's imported?
Code..
import _ from 'lodash'
import remoteConfig from '@react-native-firebase/remote-config'
class RemoteConfig {
constructor() {
if (__DEV__) {
//Fetch, no cache. activate
remoteConfig().fetchAndActivate(0)
} else {
//Fetch, cache for 5 minutes and activate
remoteConfig().fetchAndActivate()
}
}
static async build() {
await remoteConfig().setConfigSettings({
minimumFetchIntervalMillis: 300000,
})
return new RemoteConfig()
}
setDefaults(defaults) {
remoteConfig().setDefaults(defaults)
}
getValues(keys) {
return _.pick(remoteConfig().getAll(), keys)
}
getValue(key) {
return remoteConfig().getValue(key)
}
}
export let firebaseConfig = await RemoteConfig.build()
I'm using it with import {firebaseConfig} from path/to/thefile