Commit | Line | Data |
---|---|---|
1 | import { BroadcastChannel } from 'worker_threads'; | |
2 | ||
3 | import { BroadcastChannelRequest, BroadcastChannelResponse } from '../types/WorkerBroadcastChannel'; | |
4 | ||
5 | export default class WorkerBroadcastChannel extends BroadcastChannel { | |
6 | constructor() { | |
7 | super('worker'); | |
8 | } | |
9 | ||
10 | public sendRequest(request: BroadcastChannelRequest): void { | |
11 | this.postMessage(request); | |
12 | } | |
13 | ||
14 | public sendResponse(response: BroadcastChannelResponse): void { | |
15 | this.postMessage(response); | |
16 | } | |
17 | } |