diff --git a/platform/core/src/services/WorkflowStepsService/WorkflowStepsService.ts b/platform/core/src/services/WorkflowStepsService/WorkflowStepsService.ts index bd95b532685..2c023fd32a1 100644 --- a/platform/core/src/services/WorkflowStepsService/WorkflowStepsService.ts +++ b/platform/core/src/services/WorkflowStepsService/WorkflowStepsService.ts @@ -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