Created
January 2, 2016 18:56
-
-
Save chrisphelps/c7051ceddea09b0f45b0 to your computer and use it in GitHub Desktop.
Use of a helper function to hide the nested transform
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 ListenableFuture<List<Item>> getUserItemsWithConfig(User user, ListenableFuture<Config> configFuture) { | |
// transform on configFuture and call getItems(user, config) | |
... | |
} | |
public List<Item> getItems(User user, Config config) { ... } | |
ListenableFuture<User> user = getUser(args); | |
final ListenableFuture<Config> config = getConfig(args); | |
ListenableFuture<List<Item>> items = Futures.transform(user, | |
new AsyncFunction<User, List<Item>>() { | |
public ListenableFuture<List<Item>> apply(User user) throws Exception { | |
return getUserItemsWithConfig(user, config); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment