Allow other things to talk to the worker
This commit is contained in:
parent
b5f35e1f95
commit
ee9aeb8c3c
@ -42,7 +42,7 @@ export function WorkerPortal(context, worker, serialize) {
|
||||
_worker.postMessage(_serialize(type, destination, id, params));
|
||||
}
|
||||
|
||||
_worker.onmessage = function dispatcher(evt) {
|
||||
function dispatcher(evt) {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(evt.data);
|
||||
@ -80,7 +80,8 @@ export function WorkerPortal(context, worker, serialize) {
|
||||
} else {
|
||||
_resolve(thennable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function injectionPointFactory(fnId, fnName, callbackFactory) {
|
||||
return () =>
|
||||
new Promise((resolve, reject) => {
|
||||
@ -102,6 +103,8 @@ export function WorkerPortal(context, worker, serialize) {
|
||||
};
|
||||
}
|
||||
|
||||
_worker.addEventListener('message', dispatcher);
|
||||
|
||||
return isWorker()
|
||||
? new Promise(resolve => {
|
||||
contextIndex.splice(0, 0, '__init');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user