Async Library.

Light weight Kotlin library for performing tasks on background threads a.k.a WorkerThreads.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

dev.assemblage
ArtifactId

ArtifactId

asynclib
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

Async Library.
Light weight Kotlin library for performing tasks on background threads a.k.a WorkerThreads.
Project URL

Project URL

https://github.com/umang91/AsyncLib
Source Code Management

Source Code Management

https://github.com/umang91/AsyncLib

Download asynclib

How to add to project

<!-- https://jarcasting.com/artifacts/dev.assemblage/asynclib/ -->
<dependency>
    <groupId>dev.assemblage</groupId>
    <artifactId>asynclib</artifactId>
    <version>2.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/dev.assemblage/asynclib/
implementation 'dev.assemblage:asynclib:2.0.0'
// https://jarcasting.com/artifacts/dev.assemblage/asynclib/
implementation ("dev.assemblage:asynclib:2.0.0")
'dev.assemblage:asynclib:aar:2.0.0'
<dependency org="dev.assemblage" name="asynclib" rev="2.0.0">
  <artifact name="asynclib" type="aar" />
</dependency>
@Grapes(
@Grab(group='dev.assemblage', module='asynclib', version='2.0.0')
)
libraryDependencies += "dev.assemblage" % "asynclib" % "2.0.0"
[dev.assemblage/asynclib "2.0.0"]

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.10
androidx.appcompat » appcompat jar 1.2.0

Project Modules

There are no modules declared in this project.

MavenBadge

AsyncLibKotlin

Light weight Kotlin library for performing tasks on background threads a.k.a WorkerThreads.

This library has an advantage over the AsyncTask in android as one need not code extra for checking if the Activity is still in foreground or the Fragment is still attached when the async execution ends and the result needs to be updated on the UI.

Dis-advantage of using AsyncTask in your SDK/library is maximum number of concurrent tasks limit. The OS restricts the maximum number of concurrent tasks to 128, as an SDK you might be contributing to this limit which could ultimately result in some important tasks of app being dropped off.

Installation

Add the below dependency in the app level build gradle.

implementation("dev.assemblage:asynclib:$sdkVersion")

replace $sdkVersion with the latest SDK version.

Usage

Running on background thread and updating on ui thread without checks on the activity/fragment state

    runAsync {
      //code to be run asynchronously
      onUIThread {
        //code to run on main thread
      }
    }

Running on background thread and updating on ui thread only if the activity has not finished

    runAsync {
      //code to be run asynchronously
      runOnActivityThread {
        //code to run on main thread
      }
    }

Running on background thread and updating on ui thread only if the fragment has not detached

    runAsync {
      //code to be run asynchronously
      runOnFragmentThread {
        //code to run on main thread
      }
    }

Versions

Version
2.0.0