Last active
October 12, 2019 13:26
-
-
Save kirich1409/d50385e8749abb2d7fe6bc5b5551c2b7 to your computer and use it in GitHub Desktop.
Sample of new AndroidX Concurrent Futures 1.0.0
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
fun asyncOperation(): ListenableFuture<Foo> { | |
return CallbackToFutureAdapter.getFuture { completer: CallbackToFutureAdapter.Resolver<Foo> -> | |
asyncApi.load(object : OnResult { | |
override fun onSuccess(foo: Foo) { | |
completer.set(foo); | |
} | |
override fun onError(failure: Failure) { | |
completer.setException(failure.exception); | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment