| 12345678910111213141516171819202122232425262728293031 |
- 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;
|