mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-18 14:38:40 -09:00
avoid double requestAnimationFrame loop since xterm already has one
This commit is contained in:
parent
b775e23c3c
commit
57cb32de7e
1 changed files with 1 additions and 18 deletions
19
lib/index.js
19
lib/index.js
|
|
@ -46,28 +46,11 @@ rpc.on('session add', data => {
|
||||||
|
|
||||||
// we aggregate all the incoming pty events by raf
|
// we aggregate all the incoming pty events by raf
|
||||||
// debouncing, to reduce allocation and iterations
|
// debouncing, to reduce allocation and iterations
|
||||||
let req;
|
|
||||||
let objects = {};
|
|
||||||
rpc.on('session data', d => {
|
rpc.on('session data', d => {
|
||||||
// the uid is a uuid v4 so it's 36 chars long
|
// the uid is a uuid v4 so it's 36 chars long
|
||||||
const uid = d.slice(0, 36);
|
const uid = d.slice(0, 36);
|
||||||
const data = d.slice(36);
|
const data = d.slice(36);
|
||||||
if (objects[uid] === undefined) {
|
store_.dispatch(sessionActions.addSessionData(uid, data));
|
||||||
objects[uid] = data;
|
|
||||||
} else {
|
|
||||||
objects[uid] += data;
|
|
||||||
}
|
|
||||||
if (!req) {
|
|
||||||
req = requestAnimationFrame(() => {
|
|
||||||
for (const i in objects) {
|
|
||||||
if ({}.hasOwnProperty.call(objects, i)) {
|
|
||||||
store_.dispatch(sessionActions.addSessionData(i, objects[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
objects = {};
|
|
||||||
req = null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rpc.on('session data send', ({uid, data, escaped}) => {
|
rpc.on('session data send', ({uid, data, escaped}) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue