{"id":13428870,"url":"https://github.com/inaka/KillerTask","last_synced_at":"2025-03-16T02:30:39.546Z","repository":{"id":80798995,"uuid":"49956735","full_name":"inaka/KillerTask","owner":"inaka","description":"Android AsyncTask wrapper library, written in Kotlin","archived":false,"fork":false,"pushed_at":"2017-09-18T18:39:02.000Z","size":134,"stargazers_count":26,"open_issues_count":1,"forks_count":2,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-10-27T06:39:19.359Z","etag":null,"topics":["android","async","kotlin","task"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inaka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-19T14:07:20.000Z","updated_at":"2022-10-03T16:42:04.000Z","dependencies_parsed_at":"2023-03-16T19:15:15.047Z","dependency_job_id":null,"html_url":"https://github.com/inaka/KillerTask","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2FKillerTask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2FKillerTask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2FKillerTask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2FKillerTask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inaka","download_url":"https://codeload.github.com/inaka/KillerTask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815603,"owners_count":20352195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","async","kotlin","task"],"created_at":"2024-07-31T01:01:07.388Z","updated_at":"2025-03-16T02:30:39.140Z","avatar_url":"https://github.com/inaka.png","language":"Kotlin","funding_links":[],"categories":["Libraries","\u003ca name=\"concurrency\"\u003e\u003c/a\u003eConcurency \u003csup\u003e[Back ⇈](#contents)\u003c/sup\u003e"],"sub_categories":[],"readme":"KillerTask\n=====\n\nThis 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.\n\n### Abstract\nAndroid's `AsyncTasks` are highly criticized for being bad, unreliable, outdated, etc. Are they perfect? No.\nDo we have better alternatives? Sure, but sometimes all we want is a quick and simple way to run something in the background.\n\n### What is it, really?\nJust a wrapper around an `AsyncTask`, with a funny looking API.\nThe main difference between KillerTask and TinyTask is that this library is written in Kotlin language, very different from Java.\nTo 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)\n\n### How to download and install it\nAdd the following to your `build.gradle` file:\n\n```groovy\nrepositories {\n\tmaven {\n\t\turl \"https://jitpack.io\"\n\t}\n}\n\ndependencies {\n\t// ...\n  compile 'com.github.inaka:killertask:v1.2'\n  // ...\n}\n```\n\n### Code examples\n\n```kotlin\n    val onSuccess: (String) -\u003e Unit = {\n        result: String -\u003e\n        Log.wtf(\"result\", result)\n    }\n\n    val onFailed: (Exception?) -\u003e Unit = {\n        e: Exception? -\u003e\n      \tLog.wtf(\"result\", e.toString())\n    }\n\n    val doWork: () -\u003e String = {\n        \"test\" // implicit return\n    }\n\n    var killerTask = KillerTask(doWork, onSuccess, onFailed)\n```\n```kotlin\n    killerTask.go() // to execute it \n```\n```kotlin\n    killerTask.cancel() // to cancel it\n```\n\nOr simply you can do:\n\n```kotlin\n    KillerTask(\n            { \"test\" }, // task\n            {result: String -\u003e Log.wtf(\"result\", result)}, // onSuccess actions\n            {e: Exception? -\u003e Log.wtf(\"result\", e.toString())} // onFailed actions\n        ).go()\n```\n\nActually, the only strongly necessary parameter is the first one (the main task):\n\n```kotlin     \n    KillerTask({ Log.wtf(\"LOG\", \"KillerTask is awesome\") }).go() // only main task\n```\n```kotlin  \n    KillerTask(\n            { Log.wtf(\"LOG\", \"KillerTask is awesome\") }, // main task\n            { Log.wtf(\"LOG\", \"Super awesome!\")} // onSuccess\n    ).go()\n```\n```kotlin \n    KillerTask(\n            { // main task\n                Log.wtf(\"LOG\", \"KillerTask is awesome\")\n                \"super\" // implicit return\n            },\n            {}, // onSuccess is empty\n            { e: Exception? -\u003e Log.wtf(\"LOG\", e.toString()) } // onFailed\n    ).go()\n```\n\n\n### Example of an app using KillerTask\n* [Kotlillon](https://github.com/inaka/kotlillon)\n\n\n### Contact Us\nIf 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 :)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finaka%2FKillerTask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finaka%2FKillerTask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finaka%2FKillerTask/lists"}