RxEventBus

Event bus with RxJava.

License

License

Categories

Categories

EventBus Application Layer Libs Messaging
GroupId

GroupId

com.github.kubode
ArtifactId

ArtifactId

rx-eventbus
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

RxEventBus
Event bus with RxJava.
Project URL

Project URL

http://github.com/kubode/RxEventBus
Source Code Management

Source Code Management

http://github.com/kubode/RxEventBus

Download rx-eventbus

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
io.reactivex : rxjava jar 1.1.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

RxEventBus

Simple event bus using RxJava.

GitHub release Build Status codecov license

Usage

Add dependency to build.gradle.

repositories {
    jcenter()
}
dependencies {
    compile 'com.github.kubode:rxeventbus:${latestVersion}'
}

Define event class.

public class Event {
    public final int answer;
    public Event(int answer) {
        this.answer = answer;
    }
}

Subscribe handler.

RxEventBus bus = new RxEventBus();
// Do unsubscribe() to stop event handling.
Subscription subscription = bus.subscribe(Event.class, { event -> println(event.answer) });

// Supports scheduler.
bus.subscribe(ScheduledEvent.class, { event -> println("scheduled") }, Schedulers.newThread());

Post event.

bus.post(new Event(42));
// prints: 42

// Can detect unhandled.
bus.post(new OtherEvent(), { unhandledEvent -> println("unhandled") });
// prints: unhandled

License

Copyright 2016 Masatoshi Kubode

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.

Versions

Version
1.0.0