Improve event emitter

This commit is contained in:
Olivier Gagnon
2021-09-18 15:44:39 -04:00
parent 4b6a6300f5
commit 61e3959a25
15 changed files with 46 additions and 61 deletions
+2 -4
View File
@@ -11,6 +11,7 @@ import { ITerminal, Output, Link } from "../ITerminal";
import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { TerminalInput } from "./TerminalInput";
import { TerminalEvents } from "../TerminalEvents";
interface IActionTimerProps {
terminal: ITerminal;
@@ -55,10 +56,7 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
}
useEffect(() => {
const id = setInterval(() => {
if (terminal.pollChanges()) rerender();
}, 100);
return () => clearInterval(id);
return TerminalEvents.subscribe(rerender);
}, []);
function doScroll(): void {