perf(commands): skip no-op dispatch emissions

This commit is contained in:
syntaxbullet
2026-07-04 15:21:41 +02:00
parent 7188569672
commit d9e5e05183
2 changed files with 29 additions and 0 deletions

View File

@@ -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;