hyper/lib/store/write-middleware.ts

20 lines
594 B
TypeScript
Raw Permalink Normal View History

2023-07-25 09:30:19 -08:00
import type {Dispatch, Middleware} from 'redux';
2023-07-25 01:39:51 -08:00
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
2023-06-25 04:27:42 -08:00
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);
};
2020-01-02 08:49:57 -09:00
export default writeMiddleware;