kiwi.worker
v0.0.4
Published
> exmaple ```typescript //设置任务进Lib WorkerLib.Instance.setWorker(`TEST0`, `self.onmessage = (evt) => { //打印主线程传入内容 console.log(evt); self.postMessage({ status:'ok', }) }` );
Downloads
4
Readme
kiwi.worker
exmaple
//设置任务进Lib
WorkerLib.Instance.setWorker(`TEST0`,
`self.onmessage = (evt) => {
//打印主线程传入内容
console.log(evt);
self.postMessage({
status:'ok',
})
}`
);
//实例化长期任务
LongtermWorkerPool.workerInit(['TEST0']);
//可以向任务池里请求任务了
const promise = LongtermWorkerPool.acquireWorker(`TEST0`, {
workerKey: "1",
});
//promise 获取结果
promise.then((msgBus: IMessagebus) => {
//输出子线程回调结果
console.log(msgBus);
});