Skip to content

Commit

Permalink
Register when sdm instance is already available
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupuis committed Dec 14, 2018
1 parent f9e24d1 commit 73870ec
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/api/goal/GoalWithFulfillment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ export abstract class FulfillableGoal extends GoalWithPrecondition implements Re
}

public withExecutionListener(listener: GoalExecutionListener): this {
this.goalListeners.push(async gi => {
if (gi.goalEvent.uniqueName === this.uniqueName) {
return listener(gi);
}
});
const wrappedListener = async gi => {
if (gi.goalEvent.uniqueName === this.uniqueName) {
return listener(gi);
}
};
if (this.sdm) {
this.sdm.addGoalExecutionListener(wrappedListener);
}
this.goalListeners.push(wrappedListener);
return this;
}

Expand Down

0 comments on commit 73870ec

Please sign in to comment.