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

This commit is contained in:
Leonardo Campos authored and GitHub committed 2024-12-03 16:26:47 -03:00
1 parent e4595fd234
commit bca2022351
1 file changed
+6 -1
@@ -77,6 +77,7 @@ export type WorkflowStep = {
};
};
onEnter: () => void | CommandCallback[];
onExit: () => void | CommandCallback[];
};
class WorkflowStepsService extends PubSubService {
@@ -172,7 +173,7 @@ class WorkflowStepsService extends PubSubService {
const commandsManager = this._commandsManager;
if (!Array.isArray) {
if (!Array.isArray(callbacks)) {
callbacks = [callbacks];
}
@@ -203,6 +204,10 @@ class WorkflowStepsService extends PubSubService {
throw new Error(`Invalid workflowStepId (${workflowStepId})`);
}
if (this._activeWorkflowStep) {
this._invokeCallbacks(previousWorkflowStep.onExit);
}
// onEnter needs to be called before updating the Hanging Protocol because
// some displaySets need to be created before moving to the next HP stage
// (eg: convert segmentations into a chart displaySet). If needed we can