Skip to content

Commit 2ec4c6b

Browse files
committed
Publish events for errors during data loading
1 parent d151c10 commit 2ec4c6b

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/events.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ const EVENTS = {
2828
LOADING_STARTED: `${PROJECT_NAME}_loading_started`,
2929
/** Triggered when a loading of data has ended. */
3030
LOADING_ENDED: `${PROJECT_NAME}_loading_ended`,
31+
/** Triggered when an error occurs during loading of data. */
32+
LOADING_ERROR: `${PROJECT_NAME}_loading_error`,
3133
/* Triggered when the loading of an image tile has started. */
3234
FRAME_LOADING_STARTED: `${PROJECT_NAME}_frame_loading_started`,
3335
/* Triggered when the loading of an image tile has ended. */
34-
FRAME_LOADING_ENDED: `${PROJECT_NAME}_frame_loading_ended`
36+
FRAME_LOADING_ENDED: `${PROJECT_NAME}_frame_loading_ended`,
37+
/* Triggered when the error occurs during loading of an image tile. */
38+
FRAME_LOADING_ERROR: `${PROJECT_NAME}_frame_loading_ended`
3539
}
3640

3741
export default EVENTS

src/pyramid.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,7 @@ function _createTileLoadFunction ({
479479
frameNumber: frameNumbers[0],
480480
channelIdentifier: String(channel)
481481
}
482-
publish(
483-
targetElement,
484-
EVENT.FRAME_LOADING_STARTED,
485-
frameInfo
486-
)
482+
publish(targetElement, EVENT.FRAME_LOADING_STARTED, frameInfo)
487483

488484
const retrieveOptions = {
489485
studyInstanceUID,
@@ -531,11 +527,8 @@ function _createTileLoadFunction ({
531527
}
532528
).catch(
533529
(error) => {
534-
publish(
535-
targetElement,
536-
EVENT.FRAME_LOADING_ENDED,
537-
null
538-
)
530+
publish(targetElement, EVENT.FRAME_LOADING_ENDED, frameInfo)
531+
publish(targetElement, EVENT.FRAME_LOADING_ERROR, frameInfo)
539532
return Promise.reject(
540533
new Error(
541534
`Failed to load frames ${frameNumbers} ` +

src/viewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,7 +3076,8 @@ class VolumeImageViewer {
30763076
loader,
30773077
wrapX: false,
30783078
rotateWithView: true,
3079-
overlaps: false
3079+
overlaps: false,
3080+
features: new Collection([], { unique: true })
30803081
})
30813082
source.on('featuresloadstart', (event) => {
30823083
const container = this[_map].getTargetElement()
@@ -3089,6 +3090,7 @@ class VolumeImageViewer {
30893090
source.on('featuresloaderror', (event) => {
30903091
const container = this[_map].getTargetElement()
30913092
publish(container, EVENT.LOADING_ENDED)
3093+
publish(container, EVENT.LOADING_ERROR)
30923094
})
30933095

30943096
/*

0 commit comments

Comments
 (0)