Created
December 4, 2017 23:32
-
-
Save hiranya911/2140d6cbb2680639872ad0987a411efa 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
import com.google.api.core.ApiFutures; | |
import com.google.firebase.tasks.Tasks; | |
String value = "value"; | |
Exception error = new Exception("custom error"); | |
// Wrap in Tasks | |
Task<String> valueTask = Tasks.forResult(value); | |
Task<String> exceptionTask = Tasks.forException(error); | |
// Wrap in Futures | |
ApiFuture<String> valueFuture = ApiFutures.immediateFuture(value); | |
ApiFuture<String> exceptionFuture = ApiFutures.immediateFailedFuture(error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment