hyper/lib/store/write-middleware.ts

19 lines
582 B
TypeScript
Raw Normal View History

2023-06-26 01:29:50 -08:00
import type {HyperActions, HyperState} from '../hyper';
import terms from '../terms';
2023-06-26 01:29:50 -08:00
import type {Dispatch, Middleware} from 'redux';
// 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;