mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 02:11:32 +00:00
Fix terminal race condition (afterViewInit vs WS connection)
This commit is contained in:
parent
00e4c2f7b3
commit
4ac350d665
@ -7,6 +7,7 @@ import * as terminado from 'xterm/lib/addons/terminado/terminado';
|
||||
export class TerminadoService {
|
||||
xterm: Terminal;
|
||||
ws: WebSocket;
|
||||
attached = false;
|
||||
|
||||
constructor() {
|
||||
Terminal.applyAddon(fit);
|
||||
@ -47,6 +48,7 @@ export class TerminadoService {
|
||||
this.xterm.open(element);
|
||||
this.fit();
|
||||
this.xterm.blur();
|
||||
this.attached = true;
|
||||
};
|
||||
}
|
||||
|
||||
@ -54,9 +56,12 @@ export class TerminadoService {
|
||||
(<any>this.xterm).terminadoDetach(this.ws);
|
||||
this.xterm.destroy();
|
||||
this.ws.close();
|
||||
this.attached = false;
|
||||
}
|
||||
|
||||
fit() {
|
||||
(<any>this.xterm).fit();
|
||||
if (this.attached) {
|
||||
(<any>this.xterm).fit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user