Files
Papo/public/ts-build/state/store.js
Pascal Prießnitz 7a296f7b4a
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 38s
[deploy] Emit frontend bundle as ESM for browser
2025-12-04 17:06:27 +01:00

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);
}