fix: delegate all event handlers
Attaching these events directly to puppeteer functions apparently blocks and causes CPU usage to go up, slowing everything down.
related #88, 8bdecad
This commit is contained in:
parent
2820d3e72a
commit
4fe7fa93b9
1 changed files with 7 additions and 7 deletions
|
|
@ -255,7 +255,7 @@ class Client extends EventEmitter {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the connection state changes
|
* Emitted when the connection state changes
|
||||||
|
|
@ -278,11 +278,11 @@ class Client extends EventEmitter {
|
||||||
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
window.Store.Msg.on('add', (msg) => { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
|
window.Store.Msg.on('add', (msg) => { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
|
||||||
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(msg); });
|
||||||
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(msg); });
|
||||||
window.Store.Msg.on('change:ack', window.onMessageAckEvent);
|
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(msg, ack); });
|
||||||
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
window.Store.Msg.on('remove', (msg) => { if(msg.isNewMsg) window.onRemoveMessageEvent(msg); });
|
||||||
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||||
});
|
});
|
||||||
|
|
||||||
this.pupBrowser = browser;
|
this.pupBrowser = browser;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue