Skip to content

Commit 62f09ed

Browse files
fix(action-chain): fix operatorId increase order
1 parent bf9cbb2 commit 62f09ed

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/node_modules/action-chain/src/ActionBase.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,32 @@ export function actionBaseFactory<
9292
actionChain,
9393
initialActionId,
9494
(props, executionContext, newPath) => {
95-
const executionContextCopy = {
96-
__execution: {
97-
...executionContext.__execution,
98-
operatorId: executionContext.__execution.operatorId + 1,
99-
},
95+
const executionContextWithPath = {
96+
__execution: executionContext.__execution,
10097
__path: newPath
10198
? executionContext.__path.concat(newPath)
10299
: executionContext.__path.slice(),
103100
}
104-
const path = executionContextCopy.__path
101+
const path = executionContextWithPath.__path
105102
const prevResult = runOperators
106-
? runOperators(props, executionContextCopy)
103+
? runOperators(props, executionContextWithPath)
107104
: props
108105

106+
const operatorId = ++executionContextWithPath.__execution.operatorId
107+
109108
function produceResult(currentValue) {
110109
if (currentValue instanceof StopExecution) {
111110
return currentValue.value
112111
}
113112

114-
const context = actionChain.getContext(executionContextCopy)
113+
const context = actionChain.getContext(executionContextWithPath)
115114

116115
actionChain.emit('operator:start', {
117116
type,
118117
name,
119118
path,
120119
...context.__execution,
120+
operatorId,
121121
})
122122
const result = cb(currentValue, context)
123123

@@ -128,6 +128,7 @@ export function actionBaseFactory<
128128
path,
129129
isAsync: true,
130130
...context.__execution,
131+
operatorId,
131132
})
132133
return result.then((promiseResult) => {
133134
actionChain.emit('operator:end', {
@@ -137,6 +138,7 @@ export function actionBaseFactory<
137138
...context.__execution,
138139
isAsync: true,
139140
result: promiseResult,
141+
operatorId,
140142
})
141143
return promiseResult
142144
})
@@ -149,6 +151,7 @@ export function actionBaseFactory<
149151
...context.__execution,
150152
isAsync: false,
151153
result: result,
154+
operatorId,
152155
})
153156

154157
return result

0 commit comments

Comments
 (0)