{"id":22938801,"url":"https://github.com/satoshun/coroutineautodispose","last_synced_at":"2025-08-12T18:33:59.526Z","repository":{"id":41271484,"uuid":"162856017","full_name":"satoshun/CoroutineAutoDispose","owner":"satoshun","description":"Coroutine AutoDispose is an Kotlin Coroutine library for automatically disposal.","archived":false,"fork":false,"pushed_at":"2021-05-30T00:33:39.000Z","size":342,"stargazers_count":76,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-08-01T22:38:32.682Z","etag":null,"topics":["android","coroutine","kotlin"],"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/satoshun.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}},"created_at":"2018-12-23T02:17:40.000Z","updated_at":"2023-07-25T06:31:46.000Z","dependencies_parsed_at":"2022-08-10T01:43:27.893Z","dependency_job_id":null,"html_url":"https://github.com/satoshun/CoroutineAutoDispose","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satoshun%2FCoroutineAutoDispose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satoshun%2FCoroutineAutoDispose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satoshun%2FCoroutineAutoDispose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satoshun%2FCoroutineAutoDispose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satoshun","download_url":"https://codeload.github.com/satoshun/CoroutineAutoDispose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229703535,"owners_count":18110573,"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","coroutine","kotlin"],"created_at":"2024-12-14T12:28:33.003Z","updated_at":"2024-12-14T12:28:33.684Z","avatar_url":"https://github.com/satoshun.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coroutine AutoDispose\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.satoshun.coroutine.autodispose/autodispose/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.satoshun.coroutine.autodispose/autodispose)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CoroutineAutoDispose-green.svg?style=flat)](https://android-arsenal.com/details/1/7406)\n\nCoroutine AutoDispose is an Kotlin Coroutine library for automatically disposal.\n\n## Overview\n\nOften, Coroutine subscriptions need to stop in response to some event (like a Activity#onStop()).\nIn order to support this common scenario in Coroutine.\n\n### autoDisposeScope\n\nThis library provide a autoDisposeScope extension method.\nIt can be used like a [lifecycleScope](https://developer.android.com/reference/kotlin/androidx/lifecycle/package-summary#(androidx.lifecycle.LifecycleOwner).lifecycleScope:androidx.lifecycle.LifecycleCoroutineScope).\n\nIt create a [CoroutineScope](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/) for automatically disposal with Android Architecture Component Lifecycle events.\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n  override fun onCreate(savedInstanceState: Bundle?) {\n    // automatically dispose when onDestroy\n    autoDisposeScope.launch {\n      ...\n    }\n  }\n\n  override fun onResume() {\n    // automatically dispose when onPause\n    autoDisposeScope.launch {\n      ...\n    }\n  }\n}\n```\n\nIt can also be uses with Fragment and View.\n\n### Lifecycle.autoDispose(Job)\n\nThis Job an automatically disposal with Android Lifecycle events.\n\n```kotlin\nval job = launch { ... }\nlifecycle.autoDispose(job)\n```\n\n### Use with RecyclerView\n\nCoroutineScope can be used from a itemView of RecyclerView.ViewHolder.\n\n```kotlin\noverride fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {\n  holder.itemView.autoDisposeScope.launch {\n    ...\n  }\n}\n```\n\n## Download\n\n```groovy\nimplementation 'com.github.satoshun.coroutine.autodispose:autodispose:${version}'\n```\n\n## etc\n\nThis library referred [uber/AutoDispose](https://github.com/uber/AutoDispose).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatoshun%2Fcoroutineautodispose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatoshun%2Fcoroutineautodispose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatoshun%2Fcoroutineautodispose/lists"}