GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — AndroidAsync/AndroidAsync-Kotlin at master · koush/AndroidAsync

Expand file tree

/

AndroidAsync-Kotlin

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

AndroidAsync-Kotlin

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
consumer-rules.pro
consumer-rules.pro
 
 
proguard-rules.pro
proguard-rules.pro
 
 

README.md

Support for Kotlin Coroutines in AndroidAsync and Ion

Adds coroutines support to AndroidAsync and Ion.

Maven:

<dependency>
    <groupId>com.koushikdutta.async</groupId>
    <artifactId>androidasync-kotlin</artifactId>
    <version>(insert latest version)</version>
</dependency>

Gradle:

dependencies {
    compile 'com.koushikdutta.async:androidasync-kotlin:<insert latest version>'
}

Since AndroidAsync and Ion operations all returned futures, you can simply call await() on them within a Kotlin suspend function.

suspend fun getTheRobotsTxt() {
  val googleRobots = Ion.with(context)
  .load("https://google.com/robots.txt")
  .asString()
  .await()

  val githubRobots = Ion.with(context)
  .load("https://github.com/robots.txt")
  .asString()
  .await()

  return googleRobots + githubRobots
}

That's it!

But remember that the await() suspends, so if you want to fetch both robots.txt at the same time:

suspend fun getTheRobotsTxt() {
  val googleRobots = Ion.with(context)
  .load("https://google.com/robots.txt")
  .asString()

  val githubRobots = Ion.with(context)
  .load("https://github.com/robots.txt")
  .asString()

  return googleRobots.await() + githubRobots.await()
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.