26 lines
574 B
JavaScript
26 lines
574 B
JavaScript
let config = null;
|
|
let state = {};
|
|
const listeners = new Set();
|
|
export function initConfig(next) {
|
|
config = next;
|
|
state = {
|
|
guildId: next.initialGuildId,
|
|
isAdmin: next.isAdmin,
|
|
userLabel: next.userLabel
|
|
};
|
|
}
|
|
export function getConfig() {
|
|
return config;
|
|
}
|
|
export function getState() {
|
|
return state;
|
|
}
|
|
export function setState(partial) {
|
|
state = { ...state, ...partial };
|
|
listeners.forEach((l) => l(state));
|
|
}
|
|
export function subscribe(listener) {
|
|
listeners.add(listener);
|
|
return () => listeners.delete(listener);
|
|
}
|