
/**
 * 
 * @param {Object} states 
 */
export function StateStorage(states) {
    this.states = {...states};
    this.listeners = [];
    this.subscribe = (func) => {
        this.listeners.push(func);
        func({...this.states});
    };
    this.update = (changes) => {
        changes(this.states);
        for (const i of this.listeners) {
            i({...this.states});
        }
    };
    this.get = ()=>{return{...this.states}};
}