[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4212":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":15,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":15,"starSnapshotCount":15,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},4212,"RxLifecycle","trello-archive\u002FRxLifecycle","trello-archive","Lifecycle handling APIs for Android apps using RxJava",null,"Java",7653,636,198,4,0,39.41,"Apache License 2.0",false,"master",true,[],"2026-06-12 02:01:00","# RxLifecycle\n\nThis library allows one to automatically complete sequences based on a second lifecycle stream.\n\nThis capability is useful in Android, where incomplete subscriptions can cause memory leaks.\n\n## Usage\n\nYou must start with an `Observable\u003CT>` representing a lifecycle stream. Then you use `RxLifecycle` to bind\na sequence to that lifecycle.\n\nYou can bind when the lifecycle emits anything:\n\n```java\nmyObservable\n    .compose(RxLifecycle.bind(lifecycle))\n    .subscribe();\n```\n\nOr you can bind to when a specific lifecyle event occurs:\n\n```java\nmyObservable\n    .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))\n    .subscribe();\n```\n\nAlternatively, you can let RxLifecycle determine the appropriate time to end the sequence:\n\n```java\nmyObservable\n    .compose(RxLifecycleAndroid.bindActivity(lifecycle))\n    .subscribe();\n```\n\nIt assumes you want to end the sequence in the opposing lifecycle event - e.g., if subscribing during `START`, it will\nterminate on `STOP`. If you subscribe after `PAUSE`, it will terminate at the next destruction event (e.g.,\n`PAUSE` will terminate in `STOP`).\n\n## Providers\n\nWhere do lifecycles come from? Generally, they are provided by an appropriate `LifecycleProvider\u003CT>`. But where are\nthose implemented?\n\nYou have a few options for that:\n\n1. Use rxlifecycle-components and subclass the provided `RxActivity`, `RxFragment`, etc. classes.\n1. Use [Android's lifecycle](https:\u002F\u002Fdeveloper.android.com\u002Ftopic\u002Flibraries\u002Farchitecture\u002Flifecycle.html) + rxlifecycle-android-lifecycle to generate providers.\n1. Write the implementation yourself.\n\nIf you use rxlifecycle-components, just extend the appropriate class, then use the built-in `bindToLifecycle()` (or `bindUntilEvent()`) methods:\n\n```java\npublic class MyActivity extends RxActivity {\n    @Override\n    public void onResume() {\n        super.onResume();\n        myObservable\n            .compose(bindToLifecycle())\n            .subscribe();\n    }\n}\n```\n\nIf you use rxlifecycle-android-lifecycle, then you just pass your `LifecycleOwner` to `AndroidLifecycle` to generate a provider:\n\n```java\npublic class MyActivity extends LifecycleActivity {\n    private final LifecycleProvider\u003CLifecycle.Event> provider\n        = AndroidLifecycle.createLifecycleProvider(this);\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        myObservable\n            .compose(provider.bindToLifecycle())\n            .subscribe();\n    }\n}\n```\n\n## Unsubscription\n\nRxLifecycle does not actually unsubscribe the sequence. Instead it terminates the sequence. The way in which\nit does so varies based on the type:\n\n- `Observable`, `Flowable` and `Maybe` - emits `onCompleted()`\n- `Single` and `Completable` - emits `onError(CancellationException)`\n\nIf a sequence requires the `Subscription.unsubscribe()` behavior, then it is suggested that you manually handle\nthe `Subscription` yourself and call `unsubscribe()` when appropriate.\n\n## Kotlin\n\nThe rxlifecycle-kotlin module provides built-in extensions to the base RxJava types:\n\n```kotlin\nmyObservable\n    .bindToLifecycle(myView)\n    .subscribe { }\n\nmyObservable\n    .bindUntilEvent(myRxActivity, STOP)\n    .subscribe { }\n```\n\nThere is an additional rxlifecycle-android-lifecycle-kotlin module to provider extensions to work\nwith `LifecycleOwner`'s.\n\n```kotlin\n\nmyObservable\n    .bindUntilEvent(myLifecycleActivity, ON_STOP)\n    .subscribe { }\n```\n\n## Installation\n\n```gradle\nimplementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'\n\n\u002F\u002F If you want to bind to Android-specific lifecycles\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'\n\n\u002F\u002F If you want pre-written Activities and Fragments you can subclass as providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2'\n\n\u002F\u002F If you want pre-written support preference Fragments you can subclass as providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2'\n\n\u002F\u002F If you want to use Android Lifecycle for providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'\n\n\u002F\u002F If you want to use Kotlin syntax\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-kotlin:4.0.2'\n\n\u002F\u002F If you want to use Kotlin syntax with Android Lifecycle\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle-kotlin:4.0.2'\n```\n\n## License\n\n    Copyright (C) 2016 Trello\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","RxLifecycle 是一个用于 Android 应用的库，它通过 RxJava 提供了基于生命周期流自动完成序列的功能。其核心功能在于能够根据应用组件（如 Activity 或 Fragment）的生命周期自动绑定和解绑 Observable 序列，从而有效避免因订阅未完成而导致的内存泄漏问题。该库支持多种绑定方式，包括绑定到特定生命周期事件或让库自动决定序列结束的最佳时机。适用于需要管理复杂异步操作与 UI 生命周期同步的应用场景中，特别是在使用 RxJava 进行数据流处理时，能显著提高代码的健壮性和可维护性。",2,"2026-06-11 02:59:01","top_language"]