mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Removed optimistic window init.
This commit is contained in:
parent
6f96d9f450
commit
40eaebfb73
1 changed files with 1 additions and 35 deletions
|
|
@ -129,35 +129,8 @@ module.exports = class Window {
|
|||
return {session, options};
|
||||
}
|
||||
|
||||
// Optimistically create the initial session so that when the window sends
|
||||
// the first "new" IPC message, there's a session already warmed up.
|
||||
let initialSession = null;
|
||||
function createInitialSession() {
|
||||
let {session, options} = createSession();
|
||||
const initialEvents = [];
|
||||
const handleData = data => initialEvents.push(['session data', data]);
|
||||
const handleExit = () => {
|
||||
// the warmed up session should be cleaned if exit before add a new session.
|
||||
session.removeListener('data', handleData);
|
||||
session.removeListener('exit', handleExit);
|
||||
initialSession = null;
|
||||
};
|
||||
session.on('data', handleData);
|
||||
session.on('exit', handleExit);
|
||||
|
||||
function flushEvents() {
|
||||
for (let args of initialEvents) {
|
||||
rpc.emit(...args);
|
||||
}
|
||||
session.removeListener('data', handleData);
|
||||
session.removeListener('exit', handleExit);
|
||||
}
|
||||
return {session, options, flushEvents};
|
||||
}
|
||||
initialSession = createInitialSession();
|
||||
|
||||
rpc.on('new', extraOptions => {
|
||||
const {session, options} = initialSession || createSession(extraOptions);
|
||||
const {session, options} = createSession(extraOptions);
|
||||
|
||||
sessions.set(options.uid, session);
|
||||
rpc.emit('session add', {
|
||||
|
|
@ -170,13 +143,6 @@ module.exports = class Window {
|
|||
activeUid: options.activeUid
|
||||
});
|
||||
|
||||
// If this is the initial session, flush any events that might have
|
||||
// occurred while the window was initializing
|
||||
if (initialSession) {
|
||||
initialSession.flushEvents();
|
||||
initialSession = null;
|
||||
}
|
||||
|
||||
session.on('data', data => {
|
||||
rpc.emit('session data', data);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue