reducer.ts 891 B

1234567891011121314151617181920212223242526272829
  1. import { createSlice, PayloadAction } from '@reduxjs/toolkit';
  2. import { UsagesToNetwork, VariableUsageTree } from './utils';
  3. export interface VariableInspectState {
  4. usages: VariableUsageTree[];
  5. usagesNetwork: UsagesToNetwork[];
  6. }
  7. export const initialVariableInspectState: VariableInspectState = {
  8. usages: [],
  9. usagesNetwork: [],
  10. };
  11. const variableInspectReducerSlice = createSlice({
  12. name: 'templating/inspect',
  13. initialState: initialVariableInspectState,
  14. reducers: {
  15. initInspect: (state, action: PayloadAction<{ usages: VariableUsageTree[]; usagesNetwork: UsagesToNetwork[] }>) => {
  16. const { usages, usagesNetwork } = action.payload;
  17. state.usages = usages;
  18. state.usagesNetwork = usagesNetwork;
  19. },
  20. },
  21. });
  22. export const variableInspectReducer = variableInspectReducerSlice.reducer;
  23. export const { initInspect } = variableInspectReducerSlice.actions;