GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - wada811/LifecycleDispose: Dispose automatically RxJava streams using AAC Lifecycle.

BranchesTags
Open more actions menu

Latest commit

 

History

88 Commits
88 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
LifecycleDispose2
LifecycleDispose2
 
 
LifecycleDispose3
LifecycleDispose3
 
 
gradle/wrapper
gradle/wrapper
 
 
test
test
 
 
.envrc.template
.envrc.template
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
publish-module.gradle
publish-module.gradle
 
 
publish-root.gradle
publish-root.gradle
 
 
renovate.json
renovate.json
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

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

About

Dispose automatically RxJava streams using AAC Lifecycle.

medium.com/lifecycledispose

Topics

androidandroid-architecture-componentsandroid-libraryandroid-lifecycleandroid-rxjava-libraryrxjava-androidrxjava2rxjava3

Resources

Readme
Apache-2.0 license
Activity

Stars

28 stars

Watchers

0 watching

Forks

3 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.