RxBus

Event bus based on RxJava and optimized for Android

Лицензия

Лицензия

Группа

Группа

com.github.anadea
Идентификатор

Идентификатор

rxbus
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

aar
Описание

Описание

RxBus
Event bus based on RxJava and optimized for Android
Ссылка на сайт

Ссылка на сайт

https://github.com/Anadea/RxBus
Система контроля версий

Система контроля версий

https://github.com/Anadea/RxBus

Скачать rxbus

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.anadea/rxbus/ -->
<dependency>
    <groupId>com.github.anadea</groupId>
    <artifactId>rxbus</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.anadea/rxbus/
implementation 'com.github.anadea:rxbus:1.0.1'
// https://jarcasting.com/artifacts/com.github.anadea/rxbus/
implementation ("com.github.anadea:rxbus:1.0.1")
'com.github.anadea:rxbus:aar:1.0.1'
<dependency org="com.github.anadea" name="rxbus" rev="1.0.1">
  <artifact name="rxbus" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.anadea', module='rxbus', version='1.0.1')
)
libraryDependencies += "com.github.anadea" % "rxbus" % "1.0.1"
[com.github.anadea/rxbus "1.0.1"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.android.support » support-annotations jar 25.1.1
io.reactivex.rxjava2 : rxjava jar 2.0.5
io.reactivex.rxjava2 : rxandroid jar 2.0.1

Модули Проекта

Данный проект не имеет модулей.

RxBus

Event bus based on RxJava and optimized for Android.

Usage

We recommend obtaining the single instance of bus through injection or another appropriate mechanism.

Or get singleton like following:

Bus bus = BusProvider.getInstance();

Subscribing

To subscribe to an event, declare and annotate a method with @Subscribe. The method should be public and take only a single parameter.

@Subscribe
public void onEvent(SomeEvent event) {
    // TODO: Do something
}

You can also create subscription like following:

CustomSubscriber<SomeEvent> customSubscriber = bus.obtainSubscriber(SomeEvent.class,
    new Consumer<SomeEvent>() {
        @Override
        public void accept(SomeEvent someEvent) throws Exception {
            // TODO: Do something
        }
    })
    .withFilter(new Predicate<SomeEvent>() {
        @Override
        public boolean test(SomeEvent someEvent) throws Exception {
            return "Specific message".equals(someEvent.message);
        }
    })
    .withScheduler(Schedulers.trampoline());

Register and unregister your observer

To receive events, a class instance needs to register with the bus.

bus.register(this);

The customSubscriber also needs to register with the bus.

bus.registerSubscriber(this, customSubscriber);

Remember to also call the unregister method when appropriate.

bus.unregister(this);

Publishing

To publish a new event, call the post method:

bus.post(new SomeEvent("Message"));

Add RxBus to your project

Gradle:

compile 'com.github.anadea:rxbus:1.0.1'

Maven:

<dependency>
    <groupId>com.github.anadea</groupId>
    <artifactId>rxbus</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>

ProGuard

If you are using ProGuard, add the following lines to your ProGuard configuration file.

-keepattributes *Annotation*
-keepclassmembers class ** {
    @com.anadeainc.rxbus.Subscribe public *;
}

License

Copyright (C) 2017 Anadea Inc

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.
com.github.anadea

Anadea Inc

Версии библиотеки

Версия
1.0.1