handle messages in idleCallback

Summary: When receiving a message from the device, the parsing and updating is now handled in an idleCallback, with a timeout of 500ms.

Reviewed By: passy

Differential Revision: D15469094

fbshipit-source-id: c3fc70c2f082930a1a0a01078732cfd45297c391
This commit is contained in:
Daniel Büchele
2019-05-24 03:06:02 -07:00
committed by Facebook Github Bot
parent 0d769aa1c2
commit dd2d309c0c

View File

@@ -111,9 +111,10 @@ export default class Client extends EventEmitter {
const client = this;
this.responder = {
fireAndForget: (payload: {data: string}) => {
client.onMessage(payload.data);
},
fireAndForget: (payload: {data: string}) =>
requestIdleCallback(() => client.onMessage(payload.data), {
timeout: 500,
}),
};
if (conn) {