Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created December 4, 2017 23:32
Show Gist options
  • Save hiranya911/2140d6cbb2680639872ad0987a411efa to your computer and use it in GitHub Desktop.
Save hiranya911/2140d6cbb2680639872ad0987a411efa to your computer and use it in GitHub Desktop.
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