Abstraction layer over native event-based communication.
Depends on D6991
Differential D6992
[web-db] implement proxy for promise-based connection with worker kamil on Mar 7 2023, 9:18 AM. Authored by Tags None Referenced Files
Details Abstraction layer over native event-based communication. Depends on D6991 Run this code: const rawWebDbWorker = new SharedWorker('/worker/webDatabase'); const webDBWorker = new WorkerConnectionProxy( rawWebDbWorker.port, error => { console.error(error); }, ); const workerResult = await webDBWorker.scheduleOnWorker({ type: workerRequestMessageTypes.PING, text: 'PING', }); console.log('result: ', workerResult); const combinedResult = await Promise.all([ webDBWorker.scheduleOnWorker({ type: workerRequestMessageTypes.PING, text: 'PING', }), webDBWorker.scheduleOnWorker({ type: workerRequestMessageTypes.PING, text: 'PING', }), webDBWorker.scheduleOnWorker({ type: workerRequestMessageTypes.PING, text: 'PING', }), webDBWorker.scheduleOnWorker({ type: workerRequestMessageTypes.PING, text: 'PING', }), ]); console.log(combinedResult); and check results in browser, desktop, and shared worker consoles.
Diff Detail
Event Timeline
|