android rxbus github,GitHub - MindorksOpenSource/NYBus: NYBus (RxBus) - A pub-sub library for Androi...

本文介绍了一款基于RxJava的Android和Java应用的事件总线NYBus,它提供默认通道、自定义频道和线程控制等功能,简化了事件传递和管理。通过示例说明如何注册、注销、发布和接收事件,以及配置日志和使用不同场景下的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1a0415b821b7ae075331f3f5e6dccc98.png

NYBus(RxBus) - A pub-sub library for Android and Java applications.

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d696e646f726b732d6f70656e736f757263652d626c75652e737667

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d636f6d6d756e6974792d626c75652e737667

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d696e646f726b73253230416e64726f696425323053746f72652d4e594275732d626c75652e7376673f7374796c653d666c6174

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d626c75652e737667

This pub-sub library NYBus(RxBus) uses RxJava(RxJava2) for creating RxBus(RxBus2). You must have used EventBus. NYBus is very similar to the EventBus. NYBus is implemented using RxJava(RxJava2).

Overview of NYBus(RxBus) pub-sub library

NYBus is used for posting any type of event to subscribe class in Android and Java applications.

NYBus also support channel to avoid the problem of event getting received at undesirable places.

NYBus also support thread customization(thread in which the event should be posted).

NYBus is built on RxJava(RxJava2).

Using NYBus(RxBus) Library in your application

Android

compile 'com.mindorks.nybus:nybus-android:1.0.0'

Java

compile 'com.mindorks.nybus:nybus-java:1.0.0'

To run all the test cases

gradlew connectedAndroidTest test

Simple Usage

Register on default channel

NYBus.get().register(this);

Unregister from default channel

NYBus.get().unregister(this);

Post on default channel

NYBus.get().post(event);

Receive on default channel

@Subscribe

public void onEvent(Event event) {

}

Usage with specific channel

Register on specific channel

NYBus.get().register(this, Channel.ONE);

Register on more than one channel

NYBus.get().register(this, Channel.ONE, Channel.TWO);

Unregister from channel

NYBus.get().unregister(this, Channel.ONE);

Unregister from more than one channel

NYBus.get().unregister(this, Channel.ONE, Channel.TWO);

Post on a specific channel

NYBus.get().post(event, Channel.ONE);

Receive on a specific channel

@Subscribe(channelId = Channel.ONE)

public void onEvent(Event event) {

}

Receive on more than one channel

@Subscribe(channelId = {Channel.ONE, Channel.TWO})

public void onEvent(Event event) {

}

Usage with specific thread

Receive on specific thread

@Subscribe(threadType = NYThread.MAIN)

public void onEvent(Event event) {

}

Receive on a specific channel and a specific thread

@Subscribe(channelId = Channel.ONE, threadType = NYThread.IO)

public void onEvent(Event event) {

}

Enable Logging

NYBus.get().enableLogging();

It will log: D/NYBus: No target found for the eventclass com.mindorks.Event

If this library helps you in anyway, show your love ❤️ by putting a ⭐ on this project ✌️

License

Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

Contributing to NYBus

All pull requests are welcome, make sure to follow the contribution guidelines

when you submit pull request.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值