Changeset View
Changeset View
Standalone View
Standalone View
web/database/worker/web-db-worker.js
- This file was added.
// @flow | |||||
import { type SharedWorkerMessageEvent } from '../../types/worker-types.js'; | |||||
function connectHandler(event: SharedWorkerMessageEvent) { | |||||
const port: MessagePort = event.ports[0]; | |||||
tomek: Should we check if this array has at least one element? | |||||
kamilAuthorUnsubmitted Done Inline ActionsI think it's impossible for this callback to be called when there is no connection (no MessagePort) and there are no checks everywhere in the docs examples. kamil: I think it's impossible for this callback to be called when there is no connection (no… | |||||
console.log('Web database worker alive!'); | |||||
port.onmessage = async function (messageEvent: MessageEvent) { | |||||
console.log('message from main thread: ', messageEvent.data); | |||||
port.postMessage({ message: 'response from worker' }); | |||||
}; | |||||
} | |||||
self.addEventListener('connect', connectHandler); |
Should we check if this array has at least one element?