mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-08-16 07:31:38 +00:00
build
config
core
crypto
api
api.js
api_deps.js
config.js
img
lib
locales
plugins
scripts
snap
splash
.editorconfig
.eslintrc.json
.gitattributes
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
build-setup.js
build.bat
build.js
build.sh
electron-builder.yml
electron.js
install-dependencies.sh
package-lock.json
package.json
push-updates-with-travis-build.sh
run_server.bat
server.js
set-up-snap.sh
watch-inline.js
watch.js
38 lines
748 B
JavaScript
38 lines
748 B
JavaScript
import { store } from './api.js'
|
|
|
|
let config = false
|
|
let loaded = false
|
|
const configWatchers = []
|
|
const waitingForConfig = []
|
|
|
|
const subscribeToStore = () => {
|
|
if (!store) return setTimeout(() => subscribeToStore(), 50)
|
|
|
|
store.subscribe(() => {
|
|
const cA = store.getState().app
|
|
const c = store.getState().config
|
|
if (!c.loaded) return
|
|
if (!loaded) waitingForConfig.forEach(r => r(cA))
|
|
configWatchers.forEach(fn => fn(cA))
|
|
config = cA
|
|
})
|
|
}
|
|
|
|
subscribeToStore()
|
|
|
|
export function getConfig() {
|
|
return config
|
|
}
|
|
|
|
export function watchConfig(fn) {
|
|
fn(config)
|
|
configWatchers.push(fn)
|
|
}
|
|
|
|
export function waitForConfig() {
|
|
return new Promise((resolve, reject) => {
|
|
if (config) return resolve(config)
|
|
waitingForConfig.push(resolve)
|
|
})
|
|
}
|