{"id":13821786,"url":"https://github.com/AndroidKnife/RxBus","last_synced_at":"2025-05-16T15:30:46.708Z","repository":{"id":55093959,"uuid":"46855060","full_name":"AndroidKnife/RxBus","owner":"AndroidKnife","description":"Event Bus By RxJava.","archived":false,"fork":false,"pushed_at":"2021-08-27T07:54:42.000Z","size":195,"stargazers_count":2143,"open_issues_count":1,"forks_count":224,"subscribers_count":53,"default_branch":"master","last_synced_at":"2024-08-05T08:09:54.929Z","etag":null,"topics":["rxandroid","rxbus","rxjava","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/AndroidKnife.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-25T10:36:57.000Z","updated_at":"2024-08-05T03:10:20.000Z","dependencies_parsed_at":"2022-08-14T11:50:14.127Z","dependency_job_id":null,"html_url":"https://github.com/AndroidKnife/RxBus","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndroidKnife%2FRxBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndroidKnife%2FRxBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndroidKnife%2FRxBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndroidKnife%2FRxBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndroidKnife","download_url":"https://codeload.github.com/AndroidKnife/RxBus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225436284,"owners_count":17474114,"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":["rxandroid","rxbus","rxjava","rxjava2"],"created_at":"2024-08-04T08:01:28.222Z","updated_at":"2024-11-19T22:30:43.928Z","avatar_url":"https://github.com/AndroidKnife.png","language":"Java","readme":"RxBus - An event bus by [ReactiveX/RxJava](https://github.com/ReactiveX/RxJava)/[ReactiveX/RxAndroid](https://github.com/ReactiveX/RxAndroid)\n=============================\nThis is an event bus designed to allowing your application to communicate efficiently.\n\nI have use it in many projects, and now i think maybe someone would like it, so i publish it.\n\nRxBus support annotations(@produce/@subscribe), and it can provide you to produce/subscribe on other thread \nlike MAIN_THREAD, NEW_THREAD, IO, COMPUTATION, TRAMPOLINE, IMMEDIATE, even the EXECUTOR and HANDLER thread,\nmore in [EventThread](rxbus/src/main/java/com/hwangjr/rxbus/thread/EventThread.java).\n\nAlso RxBus provide the event tag to define the event. The method's first (and only) parameter and tag defines the event type.\n\n**Thanks to:**\n\n[square/otto](https://github.com/square/otto)\n\n[greenrobot/EventBus](https://github.com/greenrobot/EventBus)\n\nUsage\n--------\n\nJust 2 Steps:\n\n**STEP 1**\n\nAdd dependency to your gradle file:\n```groovy\ncompile 'com.hwangjr.rxbus:rxbus:3.0.0'\n```\nOr maven:\n``` xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.hwangjr.rxbus\u003c/groupId\u003e\n  \u003cartifactId\u003erxbus\u003c/artifactId\u003e\n  \u003cversion\u003e3.0.0\u003c/version\u003e\n  \u003ctype\u003eaar\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n**TIP:** Maybe you also use the [JakeWharton/timber](https://github.com/JakeWharton/timber) to log your message, you may need to exclude the timber (from version 1.0.4, timber dependency update from [AndroidKnife/Utils/timber](https://github.com/AndroidKnife/Utils/tree/master/timber) to JakeWharton):\n``` groovy\ncompile ('com.hwangjr.rxbus:rxbus:3.0.0') {\n    exclude group: 'com.jakewharton.timber', module: 'timber'\n}\n```\nen\nSnapshots of the development version are available in [Sonatype's `snapshots` repository](https://oss.sonatype.org/content/repositories/snapshots/).\n\n**STEP 2**\n\nJust use the provided(Any Thread Enforce):\n``` java\ncom.hwangjr.rxbus.RxBus\n```\nOr make RxBus instance is a better choice:\n``` java\npublic static final class RxBus {\n    private static Bus sBus;\n    \n    public static synchronized Bus get() {\n        if (sBus == null) {\n            sBus = new Bus();\n        }\n        return sBus;\n    }\n}\n```\n\nAdd the code where you want to produce/subscribe events, and register and unregister the class.\n``` java\npublic class MainActivity extends AppCompatActivity {\n    ...\n    \n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        ...\n        RxBus.get().register(this);\n        ...\n    }\n    \n    @Override\n    protected void onDestroy() {\n        ...\n        RxBus.get().unregister(this);\n        ...\n    }\n        \n    @Subscribe\n    public void eat(String food) {\n        // purpose\n    }\n        \n    @Subscribe(\n        thread = EventThread.IO,\n        tags = {\n            @Tag(BusAction.EAT_MORE)\n        }\n    )\n    public void eatMore(List\u003cString\u003e foods) {\n        // purpose\n    }\n    \n    @Produce\n    public String produceFood() {\n        return \"This is bread!\";\n    }\n    \n    @Produce(\n        thread = EventThread.IO,\n        tags = {\n            @Tag(BusAction.EAT_MORE)\n        }\n    )\n    public List\u003cString\u003e produceMoreFood() {\n        return Arrays.asList(\"This is breads!\");\n    }\n    \n    public void post() {\n        RxBus.get().post(this);\n    }\n    \n    public void postByTag() {\n        RxBus.get().post(Constants.EventType.TAG_STORY, this);\n    }\n    ...\n}\n```\n\n**That is all done!**\n\nLint\n--------\n\nFeatures\n--------\n* JUnit test\n* Docs\n\nHistory\n--------\nHere is the [CHANGELOG](CHANGELOG.md).\n\nFAQ\n--------\n**Q:** How to do pull requests?\u003cbr/\u003e\n**A:** Ensure good code quality and consistent formatting.\n\nLicense\n--------\n\n    Copyright 2015 HwangJR, Inc.\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","funding_links":[],"categories":["Java","进程间通信"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndroidKnife%2FRxBus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAndroidKnife%2FRxBus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndroidKnife%2FRxBus/lists"}