fix(WorkflowSteps): fixed how hooks are invoked + added support for 'onExit' hook (#4568)

This commit is contained in:
Leonardo Campos 2024-12-03 16:26:47 -03:00 committed by GitHub
parent e4595fd234
commit bca2022351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -77,6 +77,7 @@ export type WorkflowStep = {
}; };
}; };
onEnter: () => void | CommandCallback[]; onEnter: () => void | CommandCallback[];
onExit: () => void | CommandCallback[];
}; };
class WorkflowStepsService extends PubSubService { class WorkflowStepsService extends PubSubService {
@ -172,7 +173,7 @@ class WorkflowStepsService extends PubSubService {
const commandsManager = this._commandsManager; const commandsManager = this._commandsManager;
if (!Array.isArray) { if (!Array.isArray(callbacks)) {
callbacks = [callbacks]; callbacks = [callbacks];
} }
@ -203,6 +204,10 @@ class WorkflowStepsService extends PubSubService {
throw new Error(`Invalid workflowStepId (${workflowStepId})`); throw new Error(`Invalid workflowStepId (${workflowStepId})`);
} }
if (this._activeWorkflowStep) {
this._invokeCallbacks(previousWorkflowStep.onExit);
}
// onEnter needs to be called before updating the Hanging Protocol because // onEnter needs to be called before updating the Hanging Protocol because
// some displaySets need to be created before moving to the next HP stage // some displaySets need to be created before moving to the next HP stage
// (eg: convert segmentations into a chart displaySet). If needed we can // (eg: convert segmentations into a chart displaySet). If needed we can