File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ import { type RootState } from '..';
6
6
7
7
export interface CounterState {
8
8
value : number ;
9
- status : 'idle' | 'loading' | 'failed' ;
9
+ status : Response . ResponseStatus ;
10
10
}
11
11
12
12
const initialState : CounterState = {
13
13
value : 0 ,
14
- status : 'idle ' ,
14
+ status : 'loading ' ,
15
15
} ;
16
16
17
17
// The function below is called a thunk and allows us to perform async logic. It
@@ -53,7 +53,7 @@ export const counterSlice = createSlice({
53
53
// state.status = 'loading'
54
54
// })
55
55
// .addCase(incrementAsync.fulfilled, (state, action) => {
56
- // state.status = 'idle '
56
+ // state.status = 'succeeded '
57
57
// state.value += action.payload
58
58
// })
59
59
// .addCase(incrementAsync.rejected, state => {
Original file line number Diff line number Diff line change @@ -10,9 +10,14 @@ declare namespace Response {
10
10
error ?: string [ ] ;
11
11
}
12
12
13
+ /**
14
+ * 状态码
15
+ */
16
+ export type ResponseStatus = 'succeeded' | 'loading' | 'failed' ;
17
+
13
18
/** Redux state , 每项state的value */
14
19
export interface ReduxState < T > {
15
- status : keyof typeof ResponseStatus ; // RE
20
+ status : ResponseStatus ; // RE
16
21
result : T ;
17
22
error ?: string ;
18
23
}
You can’t perform that action at this time.
0 commit comments