{"id":13803859,"url":"https://github.com/JakeWharton/RxReplayingShare","last_synced_at":"2025-05-13T16:32:38.215Z","repository":{"id":37270918,"uuid":"52854530","full_name":"JakeWharton/RxReplayingShare","owner":"JakeWharton","description":"An RxJava transformer which combines replay(1), publish(), and refCount() operators.","archived":false,"fork":false,"pushed_at":"2022-09-05T07:00:43.000Z","size":577,"stargazers_count":624,"open_issues_count":3,"forks_count":28,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-12T19:49:28.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/JakeWharton.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":"2016-03-01T06:41:06.000Z","updated_at":"2025-02-28T06:55:42.000Z","dependencies_parsed_at":"2022-09-04T16:01:41.526Z","dependency_job_id":null,"html_url":"https://github.com/JakeWharton/RxReplayingShare","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxReplayingShare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxReplayingShare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxReplayingShare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxReplayingShare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JakeWharton","download_url":"https://codeload.github.com/JakeWharton/RxReplayingShare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253981954,"owners_count":21994364,"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":[],"created_at":"2024-08-04T01:00:38.538Z","updated_at":"2025-05-13T16:32:33.206Z","avatar_url":"https://github.com/JakeWharton.png","language":"Java","funding_links":[],"categories":["Utilities"],"sub_categories":[],"readme":"RxJava Replaying Share\n======================\n\n`ReplayingShare` is an RxJava 3 transformer which combines `replay(1)`, `publish()`, and\n`refCount()` operators.\n\nUnlike traditional combinations of these operators, `ReplayingShare` caches the last emitted\nvalue from the upstream observable or flowable *only* when one or more downstream subscribers are\nconnected. This allows expensive upstream sources to be shut down when no one is listening while\nalso replaying the last value seen by *any* subscriber to new ones.\n\n\n|                                                                                  | replayingShare() | replay(1).refCount() | publish().refCount() | replay(1).autoConnect(1) |\n|----------------------------------------------------------------------------------|------------------|----------------------|----------------------| -------------------------|\n| Disconnects from upstream when there are no subscribers                          | ✅               | ✅                   | ✅                   | ❌                       |\n| Replays the latest value to new subscribers when other subscribers are active    | ✅               | ✅                   | ❌                   | ✅                       |\n| Replays the latest value to new subscribers when no other subscribers are active | ✅               | ❌                   | ❌                   | ✅                       |\n\n\n\n![marble diagram](marbles.png)\n\n\nUsage\n-----\n\nApply with `compose` to an upstream `Observable` or `Flowable` and cache the resulting instance for\nall new subscribers.\n\n```java\n@Singleton class Chart {\n  private final Observable\u003cBitmap\u003e chart;\n\n  @Inject Chart(Observable\u003cList\u003cData\u003e\u003e data) {\n    chart = data.debounce(1, SECONDS)\n        .map(list -\u003e bigExpensiveRenderChartToBitmapFunction(list))\n        .compose(ReplayingShare.instance());\n  }\n\n  Observable\u003cBitmap\u003e data() {\n    return chart;\n  }\n}\n```\n\nKotlin users can use the operator via an extension function.\n\n```kotlin\n@Singleton class Chart\n@Inject constructor(data: Observable\u003cList\u003cData\u003e\u003e) {\n  val chart: Observable\u003cBitmap\u003e = data.debounce(1, SECONDS)\n      .map(list -\u003e bigExpensiveRenderChartToBitmapFunction(list))\n      .replayingShare()\n}\n```\n\nNote: This operator is designed for composition with infinite or extremely long-lived streams. Any\nterminal event will clear the cached value.\n\n\nDownload\n--------\n\nGradle:\n```groovy\nimplementation 'com.jakewharton.rx3:replaying-share:3.0.0'\n// Optional:\nimplementation 'com.jakewharton.rx3:replaying-share-kotlin:3.0.0'\n```\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx3\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share\u003c/artifactId\u003e\n  \u003cversion\u003e3.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c!-- Optional: --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx3\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share-kotlin\u003c/artifactId\u003e\n  \u003cversion\u003e3.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n### RxJava 2.x\n\nGradle:\n```groovy\nimplementation 'com.jakewharton.rx2:replaying-share:2.2.0'\n// Optional:\nimplementation 'com.jakewharton.rx2:replaying-share-kotlin:2.2.0'\n```\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx2\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share\u003c/artifactId\u003e\n  \u003cversion\u003e2.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c!-- Optional: --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx2\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share-kotlin\u003c/artifactId\u003e\n  \u003cversion\u003e2.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### RxJava 1.x\n\nGradle:\n```groovy\nimplementation 'com.jakewharton.rx:replaying-share:1.0.1'\n// Optional:\nimplementation 'com.jakewharton.rx:replaying-share-kotlin:1.0.1'\n```\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c!-- Optional: --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rx\u003c/groupId\u003e\n  \u003cartifactId\u003ereplaying-share-kotlin\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\nLicense\n-------\n\n    Copyright 2016 Jake Wharton\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.\n\n\n\n [snap]: https://oss.sonatype.org/content/repositories/snapshots/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakeWharton%2FRxReplayingShare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJakeWharton%2FRxReplayingShare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakeWharton%2FRxReplayingShare/lists"}