Skip to content
This repository was archived by the owner on Oct 19, 2019. It is now read-only.

Commit 2f6372d

Browse files
committed
fix: remove immer
1 parent 9d74380 commit 2f6372d

3 files changed

Lines changed: 21 additions & 34 deletions

File tree

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,5 @@
6969
"es",
7070
"src",
7171
"index.d.ts"
72-
],
73-
"dependencies": {
74-
"immer": "^1.7.2"
75-
}
72+
]
7673
}

src/index.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import produce from "immer";
2-
31
export default function loading(
42
config = {
53
name: 'loading',
@@ -20,25 +18,23 @@ export default function loading(
2018
},
2119
reducers: {
2220
init(state, action) {
23-
return produce(state, draft => {
24-
draft.epics = action.epics;
25-
});
21+
state.epics = action.epics;
22+
return state;
2623
},
2724
epicStart(state, action) {
28-
return produce(state, draft => {
29-
const epicCounterKey = `${action.epic}Counter`;
30-
let epicCounter = draft.epics[action.model][epicCounterKey] + action.loading;
25+
const epicCounterKey = `${action.epic}Counter`;
26+
let epicCounter = state.epics[action.model][epicCounterKey] + action.loading;
27+
28+
state.epics[action.model][epicCounterKey] = epicCounter;
29+
state.epics[action.model][action.epic] = epicCounter > 0;
3130

32-
draft.epics[action.model][epicCounterKey] = epicCounter;
33-
draft.epics[action.model][action.epic] = epicCounter > 0;
34-
});
31+
return state;
3532
},
3633
epicStop(state, action) {
37-
return produce(state, draft => {
38-
const epicCounterKey = `${action.epic}Counter`;
39-
draft.epics[action.model][epicCounterKey] = 0;
40-
draft.epics[action.model][action.epic] = false;
41-
});
34+
const epicCounterKey = `${action.epic}Counter`;
35+
state.epics[action.model][epicCounterKey] = 0;
36+
state.epics[action.model][action.epic] = false;
37+
return state;
4238
},
4339
},
4440
};
@@ -63,19 +59,17 @@ export default function loading(
6359
model.reducers.loadingEnd = loadingEnd;
6460

6561
function loadingStart(state, { payload: { epic } }) {
66-
return produce(state, draft => {
67-
const epicCounterKey = `${epic}Counter`;
68-
const epicCounter = draft.loading[epicCounterKey] + 1
69-
draft.loading[epicCounterKey] = epicCounter;
70-
draft.loading[epic] = epicCounter > 0;
71-
});
62+
const epicCounterKey = `${epic}Counter`;
63+
const epicCounter = state.loading[epicCounterKey] + 1
64+
state.loading[epicCounterKey] = epicCounter;
65+
state.loading[epic] = epicCounter > 0;
66+
return state;
7267
}
7368

7469
function loadingEnd(state, { payload: { epic } }) {
75-
return produce(state, draft => {
76-
draft.loading[`${epic}Counter`] = 0;
77-
draft.loading[epic] = false;
78-
});
70+
state.loading[`${epic}Counter`] = 0;
71+
state.loading[epic] = false;
72+
return state;
7973
}
8074
});
8175

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,10 +1899,6 @@ ignore-walk@^3.0.1:
18991899
dependencies:
19001900
minimatch "^3.0.4"
19011901

1902-
immer@^1.7.2:
1903-
version "1.7.2"
1904-
resolved "https://registry.npmjs.org/immer/-/immer-1.7.2.tgz#a51e9723c50b27e132f6566facbec1c85fc69547"
1905-
19061902
import-local@^1.0.0:
19071903
version "1.0.0"
19081904
resolved "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc"

0 commit comments

Comments
 (0)