Giter Site home page Giter Site logo

wada811 / lifecycledispose Goto Github PK

View Code? Open in Web Editor NEW
27.0 0.0 3.0 214 KB

Dispose automatically RxJava streams using AAC Lifecycle.

Home Page: https://medium.com/lifecycledispose

License: Apache License 2.0

Kotlin 100.00%
android android-library android-architecture-components android-lifecycle android-rxjava-library rxjava2 rxjava-android rxjava3

lifecycledispose's Introduction

LifecycleDispose

LifecycleDispose dispose RxJava streams on lifecycle down event that corresponding to Activity/Fragment's lifecycle state when subscribe using Android Architecture Components Lifecycle.

Lifecycle State

Usage

disposeOnPause

Dispose when onPause is called.

Observable.interval(1, TimeUnit.SECONDS)
    .subscribe()
    .disposeOnPause(this) // `this` is FragmentActivity or Fragment

disposeOnStop

Dispose when onStop is called.

Observable.interval(1, TimeUnit.SECONDS)
    .subscribe()
    .disposeOnStop(this) // `this` is FragmentActivity or Fragment

disposeOnDestroy

Dispose when onDestroy is called. If Fragment has view, dispose when onDestroyView is called.

Observable.interval(1, TimeUnit.SECONDS)
    .subscribe()
    .disposeOnDestroy(this) // `this` is FragmentActivity or Fragment

disposeOnLifecycle

Dispose on lifecycle down event that corresponding to Activity/Fragment's lifecycle state. See next section.

Observable.interval(1, TimeUnit.SECONDS)
    .subscribe()
    .disposeOnLifecycle(this) // `this` is FragmentActivity or Fragment

Lifecycle down event that corresponding to Activity/Fragment's lifecycle state

Activity

Table 1 Corresponding between Activity's lifecycle state and Lifecycle down event.

Subscribe Lifecycle.State Lifecycle.Event Dispose
onCreate INITIALIZED ON_DESTROY onDestroy
onStart CREATED ON_STOP onStop
onResume STARTED ON_PAUSE onPause
onPause STARTED ON_DESTROY onDestroy
onStop CREATED ON_DESTROY onDestroy
onDestroy DESTROYED ON_DESTROY onDestroy

Fragment

Table 2 Corresponding between Fragment's lifecycle state and Lifecycle down event.

Subscribe ViewLifecycle.State Dispose Lifecycle.State Dispose
onAttach IllegalStateException onDestroy INITIALIZED onDestroy
onCreate IllegalStateException onDestroy INITIALIZED onDestroy
onCreateView IllegalStateException onDestroyView CREATED onDestroy
onViewCreated INITIALIZED onDestroyView not called not called
onStart CREATED onStop CREATED onStop
onResume STARTED onPause STARTED onPause
onPause STARTED onDestroyView STARTED onDestroy
onStop CREATED onDestroyView CREATED onDestroy
onDestroyView DESTROYED onDestroyView not called not called
onDestroy IllegalStateException onDestroy DESTROYED onDestroy

Gradle

LifecycleDispose2

Maven Central

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.wada811.lifecycledispose:lifecycledispose2:x.y.z'
}

LifecycleDispose3

Maven Central

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.wada811.lifecycledispose:lifecycledispose3:x.y.z'
}

License

Copyright (C) 2019 wada811

Licensed under the Apache License, Version 2.0

lifecycledispose's People

Contributors

renovate[bot] avatar wada811 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lifecycledispose's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/maven-publish.yml
  • actions/checkout v4
  • actions/setup-java v3
gradle
gradle.properties
publish-module.gradle
publish-root.gradle
settings.gradle
build.gradle
  • com.android.application 8.1.2
  • com.android.library 8.1.2
  • com.diffplug.spotless 6.22.0
  • org.jetbrains.kotlin.android 1.9.10
  • io.github.gradle-nexus.publish-plugin 1.3.0
LifecycleDispose2/build.gradle
  • org.jetbrains.kotlin:kotlin-stdlib 1.9.10
  • io.reactivex.rxjava2:rxkotlin 2.4.0
  • io.reactivex.rxjava2:rxjava 2.2.21
  • androidx.fragment:fragment 1.6.1
LifecycleDispose3/build.gradle
  • org.jetbrains.kotlin:kotlin-stdlib 1.9.10
  • io.reactivex.rxjava3:rxkotlin 3.0.1
  • io.reactivex.rxjava3:rxjava 3.1.8
  • androidx.fragment:fragment 1.6.1
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.4

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.