Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ts/a11y/speech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export function SpeechMathDocumentMixin<
* @override
*/
public async done() {
await this.webworker.Stop();
await this.webworker?.Stop();
return super.done();
}
};
Expand Down
10 changes: 6 additions & 4 deletions ts/a11y/speech/WebWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,10 @@ export class WorkerHandler<N, T, D> {

/**
* Terminates the worker.
*
* @returns {Promise<any>} The promise for the worker termination.
*/
public Terminate() {
public Terminate(): Promise<any> | void {
this.debug('Terminating pending tasks');
for (const task of this.tasks) {
task.reject(
Expand All @@ -478,18 +480,18 @@ export class WorkerHandler<N, T, D> {
}
this.tasks = [];
this.debug('Terminating worker');
this.worker.terminate();
return this.worker.terminate();
}

/**
* Stop the worker and clear the values so that the worker can be
* restarted, if desired.
*/
public Stop() {
public async Stop() {
if (!this.worker) {
throw Error('Worker has not been started');
}
this.Terminate();
await this.Terminate();
this.worker = null;
this.ready = false;
}
Expand Down
2 changes: 1 addition & 1 deletion ts/core/DOMAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type PageBBox = {
export interface minWorker {
addEventListener(kind: string, listener: (event: Event) => void): void;
postMessage(msg: any): void;
terminate(): void;
terminate(): Promise<any> | void;
}

/*****************************************************************/
Expand Down