Skip to content

Instantly share code, notes, and snippets.

@ipapaste
Created February 14, 2017 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipapaste/f4807cc9e86fb2b9b3db3c917a1815d5 to your computer and use it in GitHub Desktop.
Save ipapaste/f4807cc9e86fb2b9b3db3c917a1815d5 to your computer and use it in GitHub Desktop.
public static <T> Tuple2<Future<T>, AsyncCallback<T>> make() {
final Promise<T> promise = Promise.make();
final AsyncCallback<T> callback = new AsyncCallback<T>() {
@Override
public void onFailure(final Throwable throwable) {
promise.failure(throwable);
}
@Override
public void onSuccess(final T t) {
promise.success(t);
}
};
return Tuple.of(promise.future(), callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment