@@ -6,22 +6,13 @@ export class StopExecution {
66 this . value = value
77 }
88}
9- export class ActionBase < Effects , InitialValue , Value = InitialValue > {
9+ export class ActionBase < Effects > {
1010 static nextActionId : number = 0
11- private initialActionId : number
12- private actionChain : ActionChain < Effects >
13- private runOperators : (
14- value : any ,
15- executionContext : {
16- __execution : Execution
17- __path : string [ ]
18- } ,
19- newPath ?: string
20- ) => any | Promise < any >
11+ private currentExecutionId = 0
2112 constructor (
22- actionChain : ActionChain < Effects > ,
23- initialActionId : number = ActionBase . nextActionId ++ ,
24- runOperators ?: (
13+ private actionChain : ActionChain < Effects > ,
14+ private initialActionId : number = ActionBase . nextActionId ++ ,
15+ private runOperators ?: (
2516 value : any ,
2617 executionContext : {
2718 __execution : Execution
@@ -30,20 +21,20 @@ export class ActionBase<Effects, InitialValue, Value = InitialValue> {
3021 newPath ?: string
3122 ) => any | Promise < any >
3223 ) {
33- this . actionChain = actionChain
34- this . runOperators = runOperators
35- this . initialActionId = initialActionId
24+ interface I extends ActionBase < Effects > {
25+ ( value : string ) : string
26+ displayName : string
27+ }
3628
37- let currentExecutionId = 0
38- const func = Object . assign ( function ( value ) {
29+ const instance : I = Object . assign ( function ( value ) {
3930 const initialOperator = typeof arguments [ 1 ] === 'undefined'
4031 const newPath = typeof arguments [ 2 ] === 'undefined' ? null : arguments [ 2 ]
4132 const executionContext : ExecutionContext = initialOperator
4233 ? {
4334 __execution : {
4435 operatorId : - 1 ,
4536 actionId : initialActionId ,
46- executionId : currentExecutionId ++ ,
37+ executionId : instance . currentExecutionId ++ ,
4738 } ,
4839 __path : [ ] ,
4940 }
@@ -52,7 +43,7 @@ export class ActionBase<Effects, InitialValue, Value = InitialValue> {
5243 actionChain . emit ( 'action:start' , {
5344 actionId : executionContext . __execution . actionId ,
5445 executionId : executionContext . __execution . executionId ,
55- actionName : func . displayName ,
46+ actionName : instance . displayName ,
5647 value,
5748 } )
5849 }
@@ -65,21 +56,21 @@ export class ActionBase<Effects, InitialValue, Value = InitialValue> {
6556 actionChain . emit ( 'action:end' , {
6657 actionId : executionContext . __execution . actionId ,
6758 executionId : executionContext . __execution . executionId ,
68- actionName : func . displayName ,
59+ actionName : instance . displayName ,
6960 } )
7061 } )
7162 } else if ( initialOperator ) {
7263 actionChain . emit ( 'action:end' , {
7364 actionId : executionContext . __execution . actionId ,
7465 executionId : executionContext . __execution . executionId ,
75- actionName : func . displayName ,
66+ actionName : instance . displayName ,
7667 } )
7768 }
7869
7970 return returnValue
8071 } , this ) as any
8172
82- return func
73+ return instance
8374 }
8475 getActionChain = ( ) => {
8576 return this . actionChain
0 commit comments