zzz / frontend /src /state /command-slice.ts
ar08's picture
Upload 1040 files
246d201 verified
raw
history blame contribute delete
756 Bytes
import { createSlice } from "@reduxjs/toolkit";
export type Command = {
content: string;
type: "input" | "output";
};
const initialCommands: Command[] = [];
export const commandSlice = createSlice({
name: "command",
initialState: {
commands: initialCommands,
},
reducers: {
appendInput: (state, action) => {
state.commands.push({ content: action.payload, type: "input" });
},
appendOutput: (state, action) => {
state.commands.push({ content: action.payload, type: "output" });
},
clearTerminal: (state) => {
state.commands = [];
},
},
});
export const { appendInput, appendOutput, clearTerminal } =
commandSlice.actions;
export default commandSlice.reducer;