hyper/lib/store/write-middleware.ts

18 lines
457 B
TypeScript
Raw Normal View History

import terms from '../terms';
2020-01-02 08:49:57 -09:00
import {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
2020-03-25 02:15:08 -08:00
const writeMiddleware: Middleware = () => (next) => (action) => {
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;