Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skedgo/bus
A reactive event bus for Android
https://github.com/skedgo/bus
Last synced: about 23 hours ago
JSON representation
A reactive event bus for Android
- Host: GitHub
- URL: https://github.com/skedgo/bus
- Owner: skedgo
- Created: 2015-07-07T04:00:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-01T09:11:22.000Z (over 8 years ago)
- Last Synced: 2024-03-26T15:16:48.176Z (8 months ago)
- Language: Java
- Homepage:
- Size: 58.6 KB
- Stars: 3
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bus
`Bus` is a reactive implementation for the Event Bus pattern. `Bus` is designed particularly for Android usages. This should mainly be used for communication between views, view controllers (e.g. Views, Fragments, Activities).
## Usage
```java
final Bus bus = new Bus();
```
### Publishing
```java
bus.post(ItemSelectedEvent.of(position));
```
### Subscribing
```java
// Subscription can be unsubscribed via some tools like RxLifecycle.
bus.listen()
.ofType(ItemSelectedEvent.class)
.subscribe(new Action1() {
@Override public void call(ItemSelectedEvent event) {
// TODO: Handle the event.
}
}, ErrorHandlers.trackError());
```
## Download
**Step 1**. Add the JitPack repository to your root build file.
```groovy
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
```
**Step 2**. Add the dependency.
```groovy
dependencies {
compile 'com.github.skedgo:bus:v1.0'
}
```
License
-------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 athttp://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.