-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_redux.sh
executable file
·69 lines (52 loc) · 1.26 KB
/
create_redux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
echo "Enter the name of the Redux module you wish to create:"
read name
pathAction="./src/actions/${name}Actions.js"
touch $pathAction
echo "created: $pathAction"
# write information to actions file
cat > $pathAction <<- ROM
import {
} from './types';
export const xxxxxxxx = () => {
return {
type: xxxxxxxx,
payload: xxxxxxxx
};
};
export const xxxxxxxx = () => {
return (dispatch) => {
APICALL().then(() => {
dispatch({ type: xxxxxxxx, payload: xxxxxxxx });
});
};
};
ROM
pathReducer="./src/reducers/${name}Reducer.js"
touch $pathReducer
echo "created: $pathReducer"
# write information to reducers file
cat > $pathReducer <<- RED
import {
} from '../actions/types';
const INITIAL_STATE = {
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case xxxxxxxx:
return { ...state, [action.payload.prop]: action.payload.value };
default:
return state;
}
};
RED
# write information to actions index file
pathActionsIndex="./src/actions/index.js"
cat >> $pathActionsIndex <<- EOM
export * from './${name}Actions';
EOM
# write information to reducers index file
pathReducerIndex="./src/reducers/index.js"
cat >> $pathReducerIndex <<- CVB
import ${name}Reducer from './${name}Reducer';
CVB