[bug] fix worker initialization
This commit is contained in:
parent
1349ef4994
commit
c85b4cefe8
@ -121,14 +121,15 @@ class Database {
|
|||||||
this.serviceWorkerRegistration = registration
|
this.serviceWorkerRegistration = registration
|
||||||
await this.checkForUpdates();
|
await this.checkForUpdates();
|
||||||
|
|
||||||
// Set up the message channels
|
const messageChannel = new MessageChannel();
|
||||||
this.messageChannel.port1.onmessage = this.handleAddObjectResponse;
|
|
||||||
this.messageChannelForGet.port1.onmessage = this.handleGetObjectResponse;
|
messageChannel.port1.onmessage = this.handleAddObjectResponse;
|
||||||
registration.active?.postMessage(
|
const readyRegistration = await navigator.serviceWorker.ready;
|
||||||
|
readyRegistration.active?.postMessage(
|
||||||
{
|
{
|
||||||
type: 'START',
|
type: 'START',
|
||||||
},
|
},
|
||||||
[this.messageChannel.port2],
|
[messageChannel.port2],
|
||||||
);
|
);
|
||||||
// Optionally, initialize service worker with some data
|
// Optionally, initialize service worker with some data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user