Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

CuriousNikhil/AsynKio

Repository files navigation

Asynkio : Write asynced IO/ Network calls painlessly on android


⚠️ Warning ⚠️

This library is no longer being maintained. Please make your code to use existing kotlin-coroutines features. The feature of async and await is now added in the kotlin-coroutines library itself. You can check here





Awesome Kotlin Badge| Download | Build Status | Documentation

Write your network requests, IO calls in android with Kotlin seamlessly. Asynkio Inspired by python's asyncio

What I mean is..

async {
    //All network requests on couroutines
    val response = await {
        //Get the data
        val resp = get("https://awesome.com/lib", params = mapOf("lib" to "Asynkio"))

        //Post the data
        return@await post("https://youareonfire.com/lib", data = mapOf("id" to resp.jsonObject["id"]))
    }
    //Process the result on UI thread
    if (response.statusCode == 200){
        yoTextView.text = response.text
    }
}

Yes, that's it. No retrofit. No Volley. Java/Kotlin are very bad at handling the http requests, but still Asynkio is the optimal way. No extra overhead, Seriously...No bullshit!

Another example

async {
    filename = await {
        longRunningFileOperation(content)
    }
}.onError {
    Toast.makeText(context, "Oops ! it failed",Toast.LENGTH_LONG).show()
}.finally {
    closeTheFile(filename)
}

Want to use it? Checkout full documentation over here Getting Started

Implementation

Gradle

implementation 'me.nikhilchaudhari:asynkio:{latest-version}'

Maven

<dependency>
    <groupId>me.nikhilchaudhari</groupId>
    <artifactId>asynkio</artifactId>
    <version>{latest-version}</version>
    <type>pom</type>
</dependency>

Please check releases for latest version

Documentation


License

   Copyright 2019 @ Nikhil Chaudhari

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.