Skip to content

Commit

Permalink
fix(core): fixed event order for resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcourtice committed Jun 26, 2022
1 parent 483b5f0 commit 6da77c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const EVENTS = {
},
store: {
created: 'store:created',
ready: 'store:ready',
destroyed: 'store:destroyed',
},
mutation: {
Expand Down
1 change: 1 addition & 0 deletions core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function emitCreated(store: InternalStore, state: any): void {
store.emit(EVENTS.ssr.initClient, SENDER, state);
store.emit(EVENTS.store.created, SENDER, state);
store.emit(EVENTS.ssr.initServer, SENDER, state);
store.emit(EVENTS.store.ready, SENDER, state);
store.emit(EVENTS.devtools.update, SENDER, state);
};

Expand Down
2 changes: 1 addition & 1 deletion core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class Store<TState extends BaseState = BaseState> implements Inte
this.writeState = reactive(state) as WriteState<TState>;
this.readState = readonly(this.writeState) as ReadState<TState>;

this.once(EVENTS.store.created, () => this.initialState = this.snapshot());
this.once(EVENTS.store.ready, () => this.initialState = this.snapshot());
this.on(EVENTS.devtools.reset, () => this.reset());
}

Expand Down

0 comments on commit 6da77c0

Please sign in to comment.