Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbethke committed Nov 14, 2024
1 parent 32e76f5 commit 8cafb11
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,33 @@ const PERSISTED_EVENTS = [
const STORAGEKEY_EVENTS = 'supersplat.events';

class Persistence {

events: Events;
settings: {[key: string]: any[]} = {};

constructor(events: Events){
constructor(events: Events) {
this.events = events;
this.loadSettings();

PERSISTED_EVENTS.forEach((evt) => this.register(evt));
PERSISTED_EVENTS.forEach(evt => this.register(evt));
}

loadSettings(){
loadSettings() {

const storedString = localStorage.getItem(STORAGEKEY_EVENTS);
if(storedString){
if (storedString) {
this.settings = JSON.parse(storedString);
Object.entries(this.settings).forEach(([eventName, args]) => {
this.events.fire(eventName, ...args);
});
}
}

register(eventName: string){
register(eventName: string) {
this.events.on(eventName, (...args: any[]) => {
this.settings[eventName] = Array.from(args).filter(arg => arg);
localStorage.setItem(STORAGEKEY_EVENTS, JSON.stringify(this.settings));
})
});
}
}

export {Persistence};
export { Persistence };

0 comments on commit 8cafb11

Please sign in to comment.