23 lines
528 B
JavaScript
23 lines
528 B
JavaScript
import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
const initialState = {
|
|
heapBytes: 0,
|
|
heapMB: 0,
|
|
lastUpdated: null,
|
|
};
|
|
|
|
export const heapMonitorSlice = createSlice({
|
|
name: "heapMonitor",
|
|
initialState,
|
|
reducers: {
|
|
updateHeap(state, action) {
|
|
state.heapBytes = action.payload;
|
|
state.heapMB = +(action.payload / 1024 / 1024).toFixed(2);
|
|
state.lastUpdated = new Date().toISOString();
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { updateHeap } = heapMonitorSlice.actions;
|
|
export default heapMonitorSlice.reducer;
|