{"id":13803772,"url":"https://github.com/JakeWharton/RxRelay","last_synced_at":"2025-05-13T16:32:26.471Z","repository":{"id":48502585,"uuid":"48729466","full_name":"JakeWharton/RxRelay","owner":"JakeWharton","description":"RxJava types that are both an Observable and a Consumer.","archived":false,"fork":false,"pushed_at":"2025-02-18T18:19:18.000Z","size":161,"stargazers_count":2468,"open_issues_count":0,"forks_count":126,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-04-27T20:02:04.465Z","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-29T05:33:22.000Z","updated_at":"2025-02-18T18:19:23.000Z","dependencies_parsed_at":"2025-02-28T10:11:54.171Z","dependency_job_id":"a3f50f0c-3456-4521-87c5-e1aff548dd36","html_url":"https://github.com/JakeWharton/RxRelay","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%2FRxRelay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxRelay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxRelay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2FRxRelay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JakeWharton","download_url":"https://codeload.github.com/JakeWharton/RxRelay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253981928,"owners_count":21994359,"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:37.746Z","updated_at":"2025-05-13T16:32:21.454Z","avatar_url":"https://github.com/JakeWharton.png","language":"Java","readme":"RxRelay\n=======\n\nRelays are [RxJava][rx] types which are both an `Observable` and a `Consumer`.\n\nBasically: A `Subject` except without the ability to call `onComplete` or `onError`.\n\nSubjects are useful to bridge the gap between non-Rx APIs. However, they are stateful in a damaging\nway: when they receive an `onComplete` or `onError` they no longer become usable for moving data.\nThis is the observable contract and sometimes it is the desired behavior. Most times it is not.\n\nRelays are simply Subjects without the aforementioned property. They allow you to bridge non-Rx\nAPIs into Rx easily, and without the worry of accidentally triggering a terminal state.\n\nAs more of your code moves to reactive, the need for Subjects and Relays should diminish. In the\ntransitional period, or for quickly adapting a non-Rx API, Relays provide the convenience of\nSubjects without the worry of the statefulness of terminal event behavior.\n\n\nUsage\n-----\n\n *  **`BehaviorRelay`**\n\n    Relay that emits the most recent item it has observed and all subsequent observed items to each\n    subscribed `Observer`.\n\n    ```java\n    // observer will receive all events.\n    BehaviorRelay\u003cObject\u003e relay = BehaviorRelay.createDefault(\"default\");\n    relay.subscribe(observer);\n    relay.accept(\"one\");\n    relay.accept(\"two\");\n    relay.accept(\"three\");\n    ```\n    ```java\n    // observer will receive the \"one\", \"two\" and \"three\" events, but not \"zero\"\n    BehaviorRelay\u003cObject\u003e relay = BehaviorRelay.createDefault(\"default\");\n    relay.accept(\"zero\");\n    relay.accept(\"one\");\n    relay.subscribe(observer);\n    relay.accept(\"two\");\n    relay.accept(\"three\");\n    ```\n\n *  **`PublishRelay`**\n\n    Relay that, once an `Observer` has subscribed, emits all subsequently observed items to the\n    subscriber.\n\n    ```java\n    PublishRelay\u003cObject\u003e relay = PublishRelay.create();\n    // observer1 will receive all events\n    relay.subscribe(observer1);\n    relay.accept(\"one\");\n    relay.accept(\"two\");\n    // observer2 will only receive \"three\"\n    relay.subscribe(observer2);\n    relay.accept(\"three\");\n    ```\n\n *  **`ReplayRelay`**\n\n    Relay that buffers all items it observes and replays them to any `Observer` that subscribes.\n\n    ```java\n    ReplayRelay\u003cObject\u003e relay = ReplayRelay.create();\n    relay.accept(\"one\");\n    relay.accept(\"two\");\n    relay.accept(\"three\");\n    // both of the following will get the events from above\n    relay.subscribe(observer1);\n    relay.subscribe(observer2);\n    ```\n\nAll relays use the `Relay` base class which also allows custom implementations.\n\nSee [the Javadoc][docs] for more information.\n\n(There is no `AsyncRelay` since relays have no terminal events to support its behavior.)\n\n\n\nDownload\n--------\n\nGradle:\n```groovy\nimplementation 'com.jakewharton.rxrelay3:rxrelay:3.0.1'\n```\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jakewharton.rxrelay3\u003c/groupId\u003e\n  \u003cartifactId\u003erxrelay\u003c/artifactId\u003e\n  \u003cversion\u003e3.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n\nLicense\n-------\n\n    Copyright 2014 Netflix, Inc.\n    Copyright 2015 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 [rx]: https://github.com/ReactiveX/RxJava/\n [docs]: http://jakewharton.github.io/RxRelay/\n [snap]: https://oss.sonatype.org/content/repositories/snapshots/\n","funding_links":[],"categories":["Java","Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakeWharton%2FRxRelay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJakeWharton%2FRxRelay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakeWharton%2FRxRelay/lists"}