Skip to content

Commit cf763ae

Browse files
committed
refactor(action-chain): use private keyword in constructor argument list
1 parent 93576a5 commit cf763ae

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

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

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

packages/node_modules/action-chain/src/index.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ interface INoValueAction<Context, InitialValue, Value = InitialValue>
1111
}
1212

1313
class Action<Context, InitialValue, Value = InitialValue> extends ActionBase<
14-
Context,
15-
InitialValue,
16-
Value
14+
Context
1715
> {
1816
test: (
1917
cb: (context: Context, value: Value) => void

packages/node_modules/overmind/src/Action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class Action<
2929
Effects,
3030
InitialValue,
3131
Value = InitialValue
32-
> extends ActionBase<Effects, InitialValue, Value> {
32+
> extends ActionBase<Effects> {
3333
private proxyStateTree: ProxyStateTree
3434
constructor(proxyStateTree, actionChain, initialActionId?, runOperators?) {
3535
super(actionChain, initialActionId, runOperators)

0 commit comments

Comments
 (0)