{"id":29308897,"url":"https://github.com/jzallas/rxdisposal","last_synced_at":"2026-05-19T19:32:05.665Z","repository":{"id":57725811,"uuid":"105593144","full_name":"jzallas/RxDisposal","owner":"jzallas","description":"A convenient 'garbage disposal' that can hook into an rx stream.","archived":false,"fork":false,"pushed_at":"2018-04-01T06:07:51.000Z","size":250,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-16T12:59:16.331Z","etag":null,"topics":["android","reactive-extensions","reactive-streams","rxandroid","rxdisposal","rxjava2"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/jzallas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-02T22:51:20.000Z","updated_at":"2024-04-16T12:59:16.332Z","dependencies_parsed_at":"2022-09-26T21:51:11.716Z","dependency_job_id":null,"html_url":"https://github.com/jzallas/RxDisposal","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jzallas/RxDisposal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzallas%2FRxDisposal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzallas%2FRxDisposal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzallas%2FRxDisposal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzallas%2FRxDisposal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jzallas","download_url":"https://codeload.github.com/jzallas/RxDisposal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzallas%2FRxDisposal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264032598,"owners_count":23546821,"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","reactive-extensions","reactive-streams","rxandroid","rxdisposal","rxjava2"],"created_at":"2025-07-07T07:18:39.562Z","updated_at":"2026-05-19T19:32:00.624Z","avatar_url":"https://github.com/jzallas.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"RxDisposal\n============\n\n\u003cimg src=\"/res/android_fish.png\" width=\"200\"\u003e\n\n[![CircleCI](https://circleci.com/gh/jzallas/RxDisposal/tree/master.svg?style=shield)](https://circleci.com/gh/jzallas/RxDisposal/tree/master)\n\nA convenient 'garbage disposal' that can hook into an rx streams.\n\n * Eliminate `Disposable` maintenance\n * Keep up that beautiful rx chain\n * Remove a little boilerplate\n\nGetting Started\n---------------\n##### Setup your `Disposal`\nPick a `Disposal` with the `Disposable` storage strategy that fits your needs best. Then, wrap it inside a `SubscriptionDisposal` for easier use in an rx chain:\n\n```java\nSubscriptionDisposal myDisposal = new SubscriptionDisposal(new CompositeDisposal());\n```\n\n##### Registering a `Disposable`\nNow you can plug in your `SubscriptionDisposal` every time you call `subscribe(...)` to automatically capture and remember the last `Disposable` product in that chain.\n\n```java\nmyObservable.map(a -\u003e doStuff(a))\n            .map(s -\u003e doStuff2(s))\n            .map(d -\u003e doStuff3(d))\n            .subscribe(myDisposal.wrap(f -\u003e print(f)));\n```\n\nDisposing Manually\n---------------\n`SubscriptionDisposal` is still a `Disposal`. You can call `dispose()` on it and it will delegate that request to the `Disposal` strategy you initially provided.\n\n```java\nmyDisposal.dispose();\n```\n\nDisposing Automatically\n------------------\nIf you're using the [LifecycleAware](https://github.com/jzallas/LifecycleAware) library on Android, then you can also create `Disposal`s that automatically dispose for you. The only extra thing you need to do is decide when (what lifecycle hook) you want your `Disposal` to auto dispose.\n\n```java\n@LifecycleAware(Lifecycle.Event.ON_PAUSE)\nSubscriptionAutoDiposal autoDisposal = new SubscriptionAutoDisposal(myDisposal);\n\n// this should automatically dispose in onPause(...) if you're using LifecycleAware correctly\nmyObservable.map(a -\u003e doStuff(a))\n            .subscribe(autoDisposal.wrap(b -\u003e print(b)));\n```\n\nSamples\n-------\nYou can find examples in the included [sample app](/sample-app).\n\nDependencies\n------------\n```groovy\ndependencies {\n    implementation 'com.jzallas:rxdisposal:0.1.1'\n\n    // if you want to use Automatic Disposal\n    implementation 'com.jzallas:rxdisposal-lifecycleaware:0.1.1'\n}\n```\n\n\nCredit logo to Zhuoshi Xie\n\nLicense\n-------\n\n    Copyright 2017 Jon Zallas\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://www.apache.org/licenses/LICENSE-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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzallas%2Frxdisposal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjzallas%2Frxdisposal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzallas%2Frxdisposal/lists"}