forked from fanruan/fineui
Austin.Duan
2 years ago
3 changed files with 28 additions and 13 deletions
@ -0,0 +1,26 @@ |
|||||||
|
import { ${WorkerName}MainThreadWorker } from './new_main_thread'; |
||||||
|
// 不需要一起打包的话则不需要引入这行 |
||||||
|
import { workerUrl } from 'fui-worker!../worker_thread/new_worker_thread'; |
||||||
|
|
||||||
|
// MainThread的创建在helper层处理 |
||||||
|
export class ${WorkerName}MainThreadWorkerHelper { |
||||||
|
public createMainTreadWorker() { |
||||||
|
return BI.Workers.createWorker(${WorkerName}MainThreadWorker, { |
||||||
|
workerUrl: this.urlFormatter(workerUrl), |
||||||
|
workerName: BI.UUID(), |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private urlFormatter(v: string) { |
||||||
|
return v; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export const mainThreadWorkerHelper = new ${WorkerName}MainThreadWorkerHelper(); |
||||||
|
|
||||||
|
// 调用示例 |
||||||
|
mainThreadWorkerHelper.createMainTreadWorker() |
||||||
|
.testCommunication() |
||||||
|
.then(res => { |
||||||
|
console.log(res) |
||||||
|
}) |
Loading…
Reference in new issue