Skip to content

Commit

Permalink
fix(WorkflowSteps): fixed how hooks are invoked + added support for '…
Browse files Browse the repository at this point in the history
…onExit' hook (#4568)
  • Loading branch information
lscoder authored Dec 3, 2024
1 parent e4595fd commit bca2022
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type WorkflowStep = {
};
};
onEnter: () => void | CommandCallback[];
onExit: () => void | CommandCallback[];
};

class WorkflowStepsService extends PubSubService {
Expand Down Expand Up @@ -172,7 +173,7 @@ class WorkflowStepsService extends PubSubService {

const commandsManager = this._commandsManager;

if (!Array.isArray) {
if (!Array.isArray(callbacks)) {
callbacks = [callbacks];
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bca2022

Please sign in to comment.