Skip to content

Commit

Permalink
Add convenience goal project listeners for after and before
Browse files Browse the repository at this point in the history
[changelog:added]
  • Loading branch information
cdupuis committed Oct 17, 2018
1 parent edf9dc7 commit 4b8ab7e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/api/goal/GoalInvocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,27 @@ export interface GoalInvocation extends RepoContext {
progressLog: ProgressLog;

}

/**
* Convenience function that takes a PrepareForGoalExecution and invokes it for after goal project events.
* @param listener
*/
export function afterListener(listener: PrepareForGoalExecution): GoalProjectListener {
return async (p, r, event) => {
if (event === GoalProjectListenerEvent.after) {
return listener(p, r);
}
};
}

/**
* Convenience function that takes a PrepareForGoalExecution and invokes it for before goal project events.
* @param listener
*/
export function beforeListener(listener: PrepareForGoalExecution): GoalProjectListener {
return async (p, r, event) => {
if (event === GoalProjectListenerEvent.before) {
return listener(p, r);
}
};
}

0 comments on commit 4b8ab7e

Please sign in to comment.