zzz / frontend /src /state /jupyter-slice.ts
ar08's picture
Upload 1040 files
246d201 verified
raw
history blame contribute delete
805 Bytes
import { createSlice } from "@reduxjs/toolkit";
export type Cell = {
content: string;
type: "input" | "output";
};
const initialCells: Cell[] = [];
export const jupyterSlice = createSlice({
name: "jupyter",
initialState: {
cells: initialCells,
},
reducers: {
appendJupyterInput: (state, action) => {
state.cells.push({ content: action.payload, type: "input" });
},
appendJupyterOutput: (state, action) => {
state.cells.push({ content: action.payload, type: "output" });
},
clearJupyter: (state) => {
state.cells = [];
},
},
});
export const { appendJupyterInput, appendJupyterOutput, clearJupyter } =
jupyterSlice.actions;
export const jupyterReducer = jupyterSlice.reducer;
export default jupyterReducer;