Qortal UI - Main Code Repository A User Interface for the Qortal Blockchain Project. Truly decentralized web hosting, application hosting, communications, data storage, and full infrastructure for the future global decentralized digital world.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
745 B

import { store } from './api'
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)
})
}