-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample app? #27
Comments
@qxdevelop hello, did you move on ? or did you find any sample application for that ? |
Hello, I am not very skilled in Kotlin but I found a simple way of achieving an async call to the obd.run that later produce a result on the UI thread: fun custom_run(command: ObdCommand, use_cache: Boolean = false): CompletableFuture<ObdResponse> {
val response = CompletableFuture<ObdResponse>()
runBlocking {
launch {
// What is inside "launch" block will be executed on a corouting, this code can block without blocking the calling thread
val res = obd_co.run(command, use_cache)
response.complete(res)
}
}
return response
} When the result will be ready, it will be placed in a promise on which you can register a main thread custom_run(VINCommand(), use_cache = true).thenAccept {
// Do what you want with "it", an ObdResponse object
// This code will run on the current execution thread
} |
Please could you put a sample app? Im trying to use the sample at the presentation page:
But it looks like wrong by compiler for the "obdConnection.run()". Error showed is:
Suspend function 'run' should be called only from a coroutine or another suspend function
The text was updated successfully, but these errors were encountered: