Skip to content

Commit

Permalink
fix emit event error
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcwoshizz committed Mar 16, 2023
1 parent 1fe8bbd commit dbfa3a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-cougars-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zcloak/ui-store": patch
---

fix emit event error
2 changes: 1 addition & 1 deletion packages/ui-store/src/BrowserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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][]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-store/src/BrowserStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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][]> {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-store/src/store/SessionStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class SessionStorage extends Events<StorageEvent> {
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) {
Expand Down

0 comments on commit dbfa3a0

Please sign in to comment.