Skip to content

Instantly share code, notes, and snippets.

@raultm
Created March 13, 2016 21:37
Show Gist options
  • Save raultm/805d3ae9d5a96b6b6cc5 to your computer and use it in GitHub Desktop.
Save raultm/805d3ae9d5a96b6b6cc5 to your computer and use it in GitHub Desktop.
public class GoalUseCaseImpl implements GoalUseCase{
private Match match;
private Squad squad;
Callback callback;
ApplyIncidentUseCase applyIncidentUseCase;
private int minute;
private int second;
// [...]
// Question
// Where Can I put "callback.onGoalIncidentApplied()"?. Handling the responses in applyIncidentUseCaseCallback?;
@Override
public void run()
{
Squad goalkeeperSquad = match.getOpponentGoalkeeper(squad);
applyIncidentUseCase
.setIndicent(Incident.createShotIncident(match, squad, minute, second))
.execute(applyIncidentUseCaseCallback);
;
applyIncidentUseCase
.setIndicent(Incident.createGoalReceivedIncident(match, goalkeeperSquad, minute, second))
.execute(applyIncidentUseCaseCallback);
;
applyIncidentUseCase
.setIndicent(Incident.createGoalIncident(match, squad, minute, second))
.execute(applyIncidentUseCaseCallback)
;
}
private final ApplyIncidentUseCase.Callback applyIncidentUseCaseCallback = new ApplyIncidentUseCase.Callback()
{
@Override
public void onIncidentApplied(Incident incident) {
}
@Override
public void onError(ErrorBundle errorBundle) {
}
};
}

How to handle result of Async Calls?

In my case there is an Use Case of Handle the Incidents related to a Goal, in the execution of this Use Case are involve three Use Cases

There will be a lot of similar cases in the app.

Where Can I put "callback.onGoalApplied()"?. Handling the differente responses in applyIncidentUseCaseCallback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment