@@ -35,7 +35,7 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
3535 this . initialActionId = initialActionId
3636
3737 let currentExecutionId = 0
38- return Object . assign ( function ( value ) {
38+ const func = Object . assign ( function ( value ) {
3939 const initialOperator = typeof arguments [ 1 ] === 'undefined'
4040 const newPath = typeof arguments [ 2 ] === 'undefined' ? null : arguments [ 2 ]
4141 const executionContext : ExecutionContext = initialOperator
@@ -52,6 +52,8 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
5252 actionChain . emit ( 'action:start' , {
5353 actionId : executionContext . __execution . actionId ,
5454 executionId : executionContext . __execution . executionId ,
55+ actionName : func . displayName ,
56+ value,
5557 } )
5658 }
5759 const returnValue = runOperators
@@ -63,17 +65,21 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
6365 actionChain . emit ( 'action:end' , {
6466 actionId : executionContext . __execution . actionId ,
6567 executionId : executionContext . __execution . executionId ,
68+ actionName : func . displayName ,
6669 } )
6770 } )
6871 } else if ( initialOperator ) {
6972 actionChain . emit ( 'action:end' , {
7073 actionId : executionContext . __execution . actionId ,
7174 executionId : executionContext . __execution . executionId ,
75+ actionName : func . displayName ,
7276 } )
7377 }
7478
7579 return returnValue
7680 } , this ) as any
81+
82+ return func
7783 }
7884 getActionChain = ( ) => {
7985 return this . actionChain
@@ -93,26 +99,34 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
9399 ? executionContext . __path . concat ( newPath )
94100 : executionContext . __path . slice ( ) ,
95101 }
96- const path = executionContextWithPath . __path
97102 const prevResult = this . runOperators
98103 ? this . runOperators ( props , executionContextWithPath )
99104 : props
100105
101- const operatorId = ++ executionContextWithPath . __execution . operatorId
102-
103106 const produceResult = ( currentValue ) => {
104107 if ( currentValue instanceof StopExecution ) {
105108 return currentValue
106109 }
107110
108- const context = this . actionChain . getContext ( executionContextWithPath )
111+ const thisExecution = {
112+ ...executionContextWithPath . __execution ,
113+ operatorId : executionContextWithPath . __execution . operatorId + 1 ,
114+ }
115+
116+ executionContextWithPath . __execution . operatorId ++
117+
118+ const path = executionContextWithPath . __path
119+
120+ const context = this . actionChain . getContext (
121+ thisExecution ,
122+ executionContextWithPath
123+ )
109124
110125 this . actionChain . emit ( 'operator:start' , {
111126 type,
112127 name,
113128 path,
114- ...context . __execution ,
115- operatorId,
129+ ...thisExecution ,
116130 } )
117131 const result = cb ( context , currentValue )
118132
@@ -122,18 +136,16 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
122136 name,
123137 path,
124138 isAsync : true ,
125- ...context . __execution ,
126- operatorId,
139+ ...thisExecution ,
127140 } )
128141 return result . then ( ( promiseResult ) => {
129142 this . actionChain . emit ( 'operator:end' , {
130143 type,
131144 name,
132145 path,
133- ...context . __execution ,
146+ ...thisExecution ,
134147 isAsync : true ,
135148 result : promiseResult ,
136- operatorId,
137149 } )
138150 return promiseResult
139151 } )
@@ -143,10 +155,9 @@ export class ActionBase<Context, InitialValue, Value = InitialValue> {
143155 type,
144156 name,
145157 path,
146- ...context . __execution ,
158+ ...thisExecution ,
147159 isAsync : false ,
148160 result : result ,
149- operatorId,
150161 } )
151162
152163 return result
0 commit comments