reducers.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { CombinedState, combineReducers, Reducer } from 'redux';
  2. import { initialVariableEditorState, variableEditorReducer, VariableEditorState } from '../editor/reducer';
  3. import { initialVariableInspectState, variableInspectReducer, VariableInspectState } from '../inspect/reducer';
  4. import { initialOptionPickerState, optionsPickerReducer, OptionsPickerState } from '../pickers/OptionsPicker/reducer';
  5. import { initialTransactionState, transactionReducer, TransactionState } from './transactionReducer';
  6. import { initialVariablesState, VariablesState } from './types';
  7. import { variablesReducer } from './variablesReducer';
  8. export interface TemplatingState {
  9. editor: VariableEditorState;
  10. variables: VariablesState;
  11. optionsPicker: OptionsPickerState;
  12. transaction: TransactionState;
  13. inspect: VariableInspectState;
  14. }
  15. let templatingReducers: Reducer<CombinedState<TemplatingState>>;
  16. export function getTemplatingReducers() {
  17. if (!templatingReducers) {
  18. templatingReducers = combineReducers({
  19. editor: variableEditorReducer,
  20. variables: variablesReducer,
  21. optionsPicker: optionsPickerReducer,
  22. transaction: transactionReducer,
  23. inspect: variableInspectReducer,
  24. });
  25. }
  26. return templatingReducers;
  27. }
  28. export function getInitialTemplatingState() {
  29. return {
  30. editor: initialVariableEditorState,
  31. variables: initialVariablesState,
  32. optionsPicker: initialOptionPickerState,
  33. transaction: initialTransactionState,
  34. inspect: initialVariableInspectState,
  35. };
  36. }