Created
August 7, 2017 09:44
-
-
Save drawers/7c111b271e1ef4f51c1bd0ff2e5de2f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MainRequestHelper(PlayerRepository playerRepository, GamesRepository gamesRepository, StatisticsProcessor statisticsProcessor) { | |
this.playerRepository = playerRepository; | |
this.gamesRepository = gamesRepository; | |
this.statisticsProcessor = statisticsProcessor; | |
} | |
ListenableFuture<Statistics> getStatistics(String username) { | |
return FluentFuture.from(playerRepository.retrieve(username)) | |
.transformAsync( (player) -> gamesRepository.retrieve(player.id()), directExecutor()) | |
.transform( (games) -> statisticsProcessor.process(games), directExecutor()); | |
} | |
//RxJava version | |
//return playerRepository.retrieve(username) | |
// .flatMap( (player) -> gamesRepository.retrieve(player.id())) | |
// .map(statisticsProcessor::process); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment