hyper/lib/store/write-middleware.ts
Labhansh Agrawal 36ff6e9b95 sort imports
2023-07-26 00:16:14 +05:30

19 lines
594 B
TypeScript

import type {Dispatch, Middleware} from 'redux';
import type {HyperActions, HyperState} from '../../typings/hyper';
import terms from '../terms';
// the only side effect we perform from middleware
// is to write to the react term instance directly
// to avoid a performance hit
const writeMiddleware: Middleware<{}, HyperState, Dispatch<HyperActions>> = () => (next) => (action: HyperActions) => {
if (action.type === 'SESSION_PTY_DATA') {
const term = terms[action.uid];
if (term) {
term.term.write(action.data);
}
}
next(action);
};
export default writeMiddleware;