-
Notifications
You must be signed in to change notification settings - Fork 42
LifeCycleEventHub#onDispatch receive StoreChangedPayload #328
Copy link
Copy link
Closed
Labels
Description
This is a bug.
const context = new Context({
dispatcher: new Dispatcher(),
store: storeGroup
});
context.events.onDispatch((payload, meta) => {
// payload is instanceof StoreChangedPayload in some times
});The problem case is happen when user call Store#setState.
Example: When execute ExampleUseCase, context.events.onDispatch recevive StoreChangedPayload at once.
// UseCase
class ExampleUseCase extends UseCase {
execute() {
this.dispatch({ type: "update" });
}
}
// Store
class ExampleStore extends Store {
constructor() {
super();
this.state = {};
}
receivePayload(payload) {
if (payload.type === "update") {
this.setState({ value: "new value" });
}
}
getState() {
return this.state;
}
}Reactions are currently unavailable