-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from inaka/ramabit.edit.readme
Ramabit.edit.readme
- Loading branch information
Showing
1 changed file
with
70 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,70 @@ | ||
# KillerTask | ||
KillerTask | ||
===== | ||
|
||
This is a Kotlin Android library to create async background tasks. Inspired by [TinyTask](https://github.com/inaka/TinyTask), but more beautiful and easy to use for Kotlin Android developments. | ||
|
||
### Abstract | ||
Android's `AsyncTasks` are highly criticized for being bad, unreliable, outdated, etc. Are they perfect? No. | ||
Do we have better alternatives? Sure, but sometimes all we want is a quick and simple way to run something in the background. | ||
|
||
### What is it, really? | ||
Just a wrapper around an `AsyncTask`, with a funny looking API. | ||
The main difference between KillerTask and TinyTask is that this library is written in Kotlin language, very different from Java. | ||
To learn how to use Kotlin in your Android app you can visit: [Android development with Kotlin](http://inaka.net/blog/2016/01/15/android-development-with-kotlin) | ||
|
||
### How to download and install it | ||
Add the following to your `build.gradle` file: | ||
|
||
```groovy | ||
repositories { | ||
maven { | ||
url "https://jitpack.io" | ||
} | ||
} | ||
dependencies { | ||
// ... | ||
compile 'com.github.inaka:killertask:v1.0' | ||
// ... | ||
} | ||
``` | ||
|
||
### Code Examples | ||
|
||
|
||
```kotlin | ||
val onSuccess: (String) -> Unit = { | ||
result: String -> | ||
Log.wtf("result", result) | ||
} | ||
|
||
val onFailed: (Exception?) -> Unit = { | ||
e: Exception? -> | ||
Log.wtf("result", e.toString()) | ||
} | ||
|
||
init { | ||
KillerTask(doWork(), onSuccess, onFailed).go() | ||
} | ||
|
||
fun doWork(): String { | ||
return "test" | ||
} | ||
``` | ||
or simply: | ||
|
||
```kotlin | ||
KillerTask( | ||
"test", // task | ||
{result: String -> Log.wtf("result", result)}, // onSuccess actions | ||
{e: Exception? -> Log.wtf("result", e.toString())} // onFailed actions | ||
).go() | ||
``` | ||
|
||
### Contact Us | ||
For **questions** or **general comments** regarding the use of this library, please use our public | ||
[hipchat room](http://inaka.net/hipchat). | ||
|
||
If you find any **bugs** or have a **problem** while using this library, please [open an issue](https://github.com/inaka/KillerTask/issues/new) in this repo (or a pull request :)). | ||
|
||
And you can check all of our open-source projects at [inaka.github.io](http://inaka.github.io) |