diff --git a/.changeset/nervous-cougars-brush.md b/.changeset/nervous-cougars-brush.md new file mode 100644 index 0000000..6eb2911 --- /dev/null +++ b/.changeset/nervous-cougars-brush.md @@ -0,0 +1,5 @@ +--- +"@zcloak/ui-store": patch +--- + +fix emit event error diff --git a/packages/ui-store/src/BrowserSession.ts b/packages/ui-store/src/BrowserSession.ts index 716f19b..3956ff3 100644 --- a/packages/ui-store/src/BrowserSession.ts +++ b/packages/ui-store/src/BrowserSession.ts @@ -10,7 +10,7 @@ export class BrowserSession extends BaseStore { constructor() { super(); this.#session = new SessionStorage(); - this.#session.on('store_changed', (event, ...args) => this.emit(event, ...args)); + this.#session.on('store_changed', (...args) => this.emit('store_changed', ...args)); } public async all(): Promise<[string, unknown][]> { diff --git a/packages/ui-store/src/BrowserStore.ts b/packages/ui-store/src/BrowserStore.ts index a11c644..223a408 100644 --- a/packages/ui-store/src/BrowserStore.ts +++ b/packages/ui-store/src/BrowserStore.ts @@ -10,7 +10,7 @@ export class BrowserStore extends BaseStore { constructor() { super(); this.#store = new LocalStorage(); - this.#store.on('store_changed', (event, ...args) => this.emit(event, ...args)); + this.#store.on('store_changed', (...args) => this.emit('store_changed', ...args)); } public async all(): Promise<[string, unknown][]> { diff --git a/packages/ui-store/src/store/SessionStorage.ts b/packages/ui-store/src/store/SessionStorage.ts index a56f82c..9d72d9e 100644 --- a/packages/ui-store/src/store/SessionStorage.ts +++ b/packages/ui-store/src/store/SessionStorage.ts @@ -50,8 +50,8 @@ export class SessionStorage extends Events { sessionStorage.setItem(key, val); const oldValue = this.#items.get(key); - this.#items.set(key, val); - this.emit('store_changed', key, oldValue, val); + this.#items.set(key, value); + this.emit('store_changed', key, oldValue, value); } public remove(key: string) {