Skip to content

Commit 1298a5e

Browse files
authored
Merge pull request #15 from flow-build/feature/DAT-478
refactor: handle external and internal actions
2 parents 92a72ea + 175f026 commit 1298a5e

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

__tests__/store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { configureStore } from '@reduxjs/toolkit';
22

3-
import { workflowManagerReducer } from '../src';
3+
import { workflowManagerInternalReducer } from '../src';
44

55
export const store = configureStore({
6-
reducer: { workflowManagerReducer },
6+
reducer: { workflowManagerInternalReducer },
77
});

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"name": "Wallace Ferreira",
1010
"url": "https://github.com/wallace-sf"
1111
},
12+
"contributors": [
13+
{
14+
"name": "Leonardo Abe",
15+
"url": "https://github.com/leonardoabe"
16+
}
17+
],
1218
"main": "dist/index.js",
1319
"typings": "dist/index.d.ts",
1420
"keywords": [
@@ -122,4 +128,4 @@
122128
"yarn fmt"
123129
]
124130
}
125-
}
131+
}

src/WorkflowManagerConfig.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { matches, exec } from 'mqtt-pattern';
44
import invariant from 'tiny-warning';
55

66
import { createWorkflowAction } from './ducks/utils';
7-
import { addProcess, removeProcess } from './ducks/workflowManager.slice';
7+
import {
8+
addProcess,
9+
removeProcess,
10+
} from './ducks/workflowManagerInternal.slice';
811
import { WorkflowManagerConfigProps, IClientUnsubscribeOptions } from './types';
912
import {
1013
ERROR_MESSAGES,

src/ducks/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export { default as workflowManagerReducer } from './workflowManager.slice';
1+
export { default as workflowManagerInternalReducer } from './workflowManagerInternal.slice';
2+
export const prefix = '@@workflowManagerExternal';

src/ducks/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createAction } from '@reduxjs/toolkit';
22

3-
import { prefix } from './workflowManager.slice';
3+
import { prefix } from '.';
44

55
export const createWorkflowAction = (
66
workflowAction: string,
77
payload: Record<string, unknown>,
88
) => {
9-
const actionName = `${prefix}/external/${workflowAction}`;
9+
const actionName = `${prefix}/${workflowAction}`;
1010

1111
return createAction<typeof payload>(actionName)(payload);
1212
};

src/ducks/workflowManager.slice.ts renamed to src/ducks/workflowManagerInternal.slice.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
33
import { WorkflowManagerState } from './types';
44

55
const Types = {
6-
addProcess: 'internal/ADD_PROCESS',
7-
removeProcess: 'internal/REMOVE_PROCESS',
6+
addProcess: 'ADD_PROCESS',
7+
removeProcess: 'REMOVE_PROCESS',
88
};
99

1010
const initialState: WorkflowManagerState = {
1111
activeProcesses: [],
1212
};
1313

14-
export const workflowManagerSlice = createSlice({
15-
name: '@@workflowManager',
14+
export const workflowManagerInternalSlice = createSlice({
15+
name: '@@workflowManagerInternal',
1616
initialState,
1717
reducers: {
1818
[Types.addProcess]: (state, action: PayloadAction<string>) => {
@@ -26,8 +26,9 @@ export const workflowManagerSlice = createSlice({
2626
},
2727
});
2828

29-
export const prefix = workflowManagerSlice.name;
30-
export const addProcess = workflowManagerSlice.actions[Types.addProcess];
31-
export const removeProcess = workflowManagerSlice.actions[Types.removeProcess];
29+
export const addProcess =
30+
workflowManagerInternalSlice.actions[Types.addProcess];
31+
export const removeProcess =
32+
workflowManagerInternalSlice.actions[Types.removeProcess];
3233

33-
export default workflowManagerSlice.reducer;
34+
export default workflowManagerInternalSlice.reducer;

0 commit comments

Comments
 (0)