peanut

Additional

Language
Kotlin
Version
v1.0.0 (Jun 14, 2018)
Created
Jun 13, 2018
Updated
May 6, 2019 (Retired)
Owner
Taylan Sabırcan (savepopulation)
Contributor
Taylan Sabırcan (savepopulation)
1
Activity
Badge
Generate
Download
Source code

peanut


A minimal Android library to handle heavy works in worker threads easily.

How to use?

It's really easy to use.

Create your peanut.

val peanut = object : Peanut<String>() {
            override fun call() {
                var count = 0
                for (i in 0 until 100000) {
                    count += count
                }
                onSuccess(count.toString())
            }
}

and Schedule it

peanut.runOn(Schedulers.io())
                .receiveOn(Schedulers.main())
                .run(object : Peanut.Subscriber<String> {

                    override fun onComplete(data: String) {
                        count.text = data
                    }

                    override fun onError(e: Error) {
                        e.printStackTrace()
                    }
})

Dependency

Add it in your root build.gradle at the end of repositories:

allprojects {
 repositories {
  ...
  maven { url 'https://jitpack.io' }
 }
}

Add the dependency

dependencies {
  implementation 'com.github.savepopulation:peanut:v1.0.0'
}