Files
pybricks-code/src/reducers/editor.ts
T
David Lechner 6e4b22f841 Add common top-level Action type
This makes for better type inference.
2020-05-26 21:20:08 -05:00

24 lines
661 B
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2020 The Pybricks Authors
import { Ace } from 'ace-builds';
import { Reducer, combineReducers } from 'redux';
import { Action } from '../actions';
import { EditorActionType } from '../actions/editor';
type CurrentEditSession = Ace.EditSession | null;
const current: Reducer<CurrentEditSession, Action> = (state = null, action) => {
switch (action.type) {
case EditorActionType.Current:
return action.editSession || null;
default:
return state;
}
};
export interface EditorState {
current: CurrentEditSession;
}
export default combineReducers({ current });