### Add JitPack Repository to Gradle Source: https://github.com/zhihu/rxlifecycle/blob/master/README.md This snippet shows how to add the JitPack Maven repository to your project's `build.gradle` file. Adding this repository is a prerequisite for fetching the RxLifecycle library dependencies. ```gradle repositories { maven { url "https://jitpack.io" } } ``` -------------------------------- ### Add RxLifecycle Library Dependencies Source: https://github.com/zhihu/rxlifecycle/blob/master/README.md Illustrates how to declare the RxLifecycle library and its optional compact version as dependencies in your `build.gradle` file. Replace `{lastest-version}` with the actual latest version of the library to integrate it into your Android project. ```gradle dependencies { compile 'com.github.nekocode.rxlifecycle:rxlifecycle:{lastest-version}' compile 'com.github.nekocode.rxlifecycle:rxlifecycle-compact:{lastest-version}' // Optional } ``` -------------------------------- ### Unsubscribe RxJava Observable with RxLifecycle Source: https://github.com/zhihu/rxlifecycle/blob/master/README.md Demonstrates the simplest way to use RxLifecycle to automatically dispose an RxJava observable sequence. By composing with `RxLifecycle.bind(this).disposeObservableWhen(LifecycleEvent.DESTROY_VIEW)`, the observable will be unsubscribed when the specified lifecycle event occurs, preventing further emissions. ```java Observable.interval(0, 2, TimeUnit.SECONDS) // ... .compose(RxLifecycle.bind(this) .disposeObservableWhen(LifecycleEvent.DESTROY_VIEW)) .subscribe(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.