|
1 | 1 | import type { ReadonlyHashMap } from '@reactodia/hashmap'; |
2 | 2 |
|
3 | | -import { AbortScope } from '../coreUtils/async'; |
4 | 3 | import { AnyEvent, EventSource, Events } from '../coreUtils/events'; |
5 | 4 | import { Translation, TranslatedText } from '../coreUtils/i18n'; |
6 | 5 |
|
@@ -157,7 +156,7 @@ export class DataDiagramModel extends DiagramModel implements DataGraphStructure |
157 | 156 | private readonly translation: Translation; |
158 | 157 |
|
159 | 158 | private dataGraph = new DataGraph(); |
160 | | - private loadingScope: AbortScope | undefined; |
| 159 | + private loadingScope: AbortController | undefined; |
161 | 160 | private _dataProvider: DataProvider; |
162 | 161 | private _locale: DataLocaleProvider; |
163 | 162 | private fetcher: DataFetcher; |
@@ -390,11 +389,15 @@ export class DataDiagramModel extends DiagramModel implements DataGraphStructure |
390 | 389 | translation: this.translation, |
391 | 390 | }); |
392 | 391 |
|
393 | | - this.loadingScope = new AbortScope(parentSignal); |
| 392 | + const scope = new AbortController(); |
| 393 | + this.loadingScope = scope; |
| 394 | + const onParentSignalAbort = () => scope.abort(); |
| 395 | + |
394 | 396 | this.extendedSource.trigger('loadingStart', {source: this}); |
395 | 397 | const signal = this.loadingScope.signal; |
396 | | - |
| 398 | + |
397 | 399 | try { |
| 400 | + parentSignal?.addEventListener('abort', onParentSignalAbort); |
398 | 401 | signal.throwIfAborted(); |
399 | 402 |
|
400 | 403 | this.setLinkSettings(diagram.linkTypeOptions ?? []); |
@@ -438,6 +441,7 @@ export class DataDiagramModel extends DiagramModel implements DataGraphStructure |
438 | 441 | this.extendedSource.trigger('loadingError', {source: this, error}); |
439 | 442 | throw new Error('Reactodia: failed to import a layout', {cause: error}); |
440 | 443 | } finally { |
| 444 | + parentSignal?.removeEventListener('abort', onParentSignalAbort); |
441 | 445 | this.loadingScope?.abort(); |
442 | 446 | this.loadingScope = undefined; |
443 | 447 | } |
|
0 commit comments