Skip to content

Commit 8ebfada

Browse files
authored
Merge pull request #274 from skspade/bugfix/208-terminate-worker
#208 Add worker termination conditions and method
2 parents 9df787f + 1f131be commit 8ebfada

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/js/elk-api.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*******************************************************************************
22
* Copyright (c) 2017 Kiel University and others.
3-
*
4-
* This program and the accompanying materials are made
5-
* available under the terms of the Eclipse Public License 2.0
6-
* which is available at https://www.eclipse.org/legal/epl-2.0/
7-
*
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
88
* SPDX-License-Identifier: EPL-2.0
99
*******************************************************************************/
1010
export default class ELK {
@@ -89,6 +89,7 @@ export default class ELK {
8989
}
9090

9191
terminateWorker() {
92+
if(this.worker)
9293
this.worker.terminate()
9394
}
9495

@@ -144,11 +145,11 @@ class PromisedWorker {
144145
}
145146

146147
terminate() {
147-
if (this.worker.terminate) {
148+
if (this.worker) {
148149
this.worker.terminate()
149150
}
150151
}
151-
152+
152153
convertGwtStyleError(err) {
153154
if (!err) {
154155
return
@@ -167,5 +168,5 @@ class PromisedWorker {
167168
}
168169
delete err['__java$exception']
169170
}
170-
}
171+
}
171172
}

typings/elk-api.d.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*******************************************************************************
22
* Copyright (c) 2019 TypeFox and others.
3-
*
4-
* This program and the accompanying materials are made
5-
* available under the terms of the Eclipse Public License 2.0
6-
* which is available at https://www.eclipse.org/legal/epl-2.0/
7-
*
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
88
* SPDX-License-Identifier: EPL-2.0
99
*******************************************************************************/
1010

@@ -116,6 +116,7 @@ export interface ELK {
116116
knownLayoutAlgorithms(): Promise<ElkLayoutAlgorithmDescription[]>
117117
knownLayoutOptions(): Promise<ElkLayoutOptionDescription[]>
118118
knownLayoutCategories(): Promise<ElkLayoutCategoryDescription[]>
119+
terminateWorker(): void;
119120
}
120121

121122
export interface ELKConstructorArguments {

0 commit comments

Comments
 (0)