Skip to content

Commit 77686fc

Browse files
committed
Remove Action / ActionType / ThunkAction
We rename `SimpleThunkAction` to `ThunkAction` as there's no ambiguity now.
1 parent 3b97fd7 commit 77686fc

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

ui/frontend/BuildMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface BuildMenuProps {
1414
close: () => void;
1515
}
1616

17-
const useDispatchAndClose = (action: () => actions.SimpleThunkAction, close: () => void) => {
17+
const useDispatchAndClose = (action: () => actions.ThunkAction, close: () => void) => {
1818
const dispatch = useAppDispatch();
1919

2020
return useCallback(() => {

ui/frontend/actions.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
parseMode,
2020
} from './types';
2121

22-
import { performCommonExecute, wsExecuteRequest } from './reducers/output/execute';
22+
import { performCommonExecute } from './reducers/output/execute';
2323
import { performGistLoad } from './reducers/output/gist';
2424
import { performCompileToAssemblyOnly } from './reducers/output/assembly';
2525
import { performCompileToHirOnly } from './reducers/output/hir';
@@ -36,10 +36,7 @@ import {
3636
changePrimaryAction,
3737
} from './reducers/configuration';
3838

39-
export type ThunkAction<T = void> = ReduxThunkAction<T, State, {}, Action>;
40-
export type SimpleThunkAction<T = void> = ReduxThunkAction<T, State, {}, AnyAction>;
41-
42-
export enum ActionType {}
39+
export type ThunkAction<T = void> = ReduxThunkAction<T, State, {}, AnyAction>;
4340

4441
export const reExecuteWithBacktrace = (): ThunkAction => dispatch => {
4542
dispatch(changeBacktrace(Backtrace.Enabled));
@@ -164,15 +161,3 @@ export function showExample(code: string): ThunkAction {
164161
dispatch(editCode(code));
165162
};
166163
}
167-
168-
export type Action =
169-
| ReturnType<typeof changeBacktrace>
170-
| ReturnType<typeof changeChannel>
171-
| ReturnType<typeof changeEditionRaw>
172-
| ReturnType<typeof changeMode>
173-
| ReturnType<typeof changePrimaryAction>
174-
| ReturnType<typeof editCode>
175-
| ReturnType<typeof addCrateType>
176-
| ReturnType<typeof navigateToIndex>
177-
| ReturnType<typeof wsExecuteRequest>
178-
;

ui/frontend/compileActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AsyncThunk, createAsyncThunk } from '@reduxjs/toolkit';
22
import * as z from 'zod';
33

4-
import { SimpleThunkAction } from './actions';
4+
import { ThunkAction } from './actions';
55
import { jsonPost, routes } from './api';
66
import { compileRequestPayloadSelector } from './selectors';
77

@@ -33,7 +33,7 @@ interface Props {
3333

3434
interface CompileActions {
3535
action: AsyncThunk<CompileResponseBody, CompileRequestBody, {}>;
36-
performCompile: () => SimpleThunkAction;
36+
performCompile: () => ThunkAction;
3737
}
3838

3939
export const makeCompileActions = ({ sliceName, target }: Props): CompileActions => {
@@ -42,7 +42,7 @@ export const makeCompileActions = ({ sliceName, target }: Props): CompileActions
4242
return CompileResponseBody.parseAsync(d);
4343
});
4444

45-
const performCompile = (): SimpleThunkAction => (dispatch, getState) => {
45+
const performCompile = (): ThunkAction => (dispatch, getState) => {
4646
const state = getState();
4747
const body = compileRequestPayloadSelector(state, { target });
4848
dispatch(action(body));

ui/frontend/reducers/configuration.ts

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

3-
import { SimpleThunkAction } from '../actions';
3+
import { ThunkAction } from '../actions';
44
import {
55
AssemblyFlavor,
66
Backtrace,
@@ -138,7 +138,7 @@ export const {
138138
} = slice.actions;
139139

140140
export const changeEdition =
141-
(edition: Edition): SimpleThunkAction =>
141+
(edition: Edition): ThunkAction =>
142142
(dispatch) => {
143143
if (edition === Edition.Rust2024) {
144144
dispatch(changeChannel(Channel.Nightly));

ui/frontend/reducers/output/execute.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AnyAction, Draft, createAsyncThunk, createSlice } from '@reduxjs/toolkit';
22
import * as z from 'zod';
33

4-
import { SimpleThunkAction } from '../../actions';
4+
import { ThunkAction } from '../../actions';
55
import { jsonPost, routes } from '../../api';
66
import { executeRequestPayloadSelector, executeViaWebsocketSelector } from '../../selectors';
77
import { Channel, Edition, Mode } from '../../types';
@@ -194,7 +194,7 @@ const slice = createSlice({
194194
export const { wsExecuteRequest } = slice.actions;
195195

196196
export const performCommonExecute =
197-
(crateType: string, tests: boolean): SimpleThunkAction =>
197+
(crateType: string, tests: boolean): ThunkAction =>
198198
(dispatch, getState) => {
199199
const state = getState();
200200
const body = executeRequestPayloadSelector(state, { crateType, tests });
@@ -208,7 +208,7 @@ export const performCommonExecute =
208208
};
209209

210210
const dispatchWhenSequenceNumber =
211-
<A extends AnyAction>(cb: (sequenceNumber: number) => A): SimpleThunkAction =>
211+
<A extends AnyAction>(cb: (sequenceNumber: number) => A): ThunkAction =>
212212
(dispatch, getState) => {
213213
const state = getState();
214214
const { sequenceNumber } = state.output.execute;
@@ -218,17 +218,17 @@ const dispatchWhenSequenceNumber =
218218
}
219219
};
220220

221-
export const wsExecuteStdin = (payload: string): SimpleThunkAction =>
221+
export const wsExecuteStdin = (payload: string): ThunkAction =>
222222
dispatchWhenSequenceNumber((sequenceNumber) =>
223223
slice.actions.wsExecuteStdin(payload, sequenceNumber),
224224
);
225225

226-
export const wsExecuteStdinClose = (): SimpleThunkAction =>
226+
export const wsExecuteStdinClose = (): ThunkAction =>
227227
dispatchWhenSequenceNumber((sequenceNumber) =>
228228
slice.actions.wsExecuteStdinClose(undefined, sequenceNumber),
229229
);
230230

231-
export const wsExecuteKill = (): SimpleThunkAction =>
231+
export const wsExecuteKill = (): ThunkAction =>
232232
dispatchWhenSequenceNumber((sequenceNumber) =>
233233
slice.actions.wsExecuteKill(undefined, sequenceNumber),
234234
);

0 commit comments

Comments
 (0)