perf(commands): skip no-op dispatch emissions
This commit is contained in:
@@ -25,6 +25,9 @@ export function createCommandDispatcher(options: {
|
||||
const currentState = options.getState();
|
||||
const context: CommandContext = { state: currentState };
|
||||
const executedState = command.execute(context, payload);
|
||||
if (executedState === currentState) {
|
||||
return currentState;
|
||||
}
|
||||
const nextState = shouldRecordHistory(commandId, currentState, executedState) ? recordHistory(currentState, executedState) : executedState;
|
||||
options.setState(nextState);
|
||||
return nextState;
|
||||
|
||||
Reference in New Issue
Block a user