https://github.com/valkryst/vradio
A thread-safe implementation of the publish-subscribe pattern.
https://github.com/valkryst/vradio
publish publish-subscribe radio receiver subscriptions
Last synced: 6 months ago
JSON representation
A thread-safe implementation of the publish-subscribe pattern.
- Host: GitHub
- URL: https://github.com/valkryst/vradio
- Owner: Valkryst
- License: mit
- Created: 2017-01-02T20:37:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T13:17:23.000Z (over 2 years ago)
- Last Synced: 2025-03-30T08:11:16.957Z (7 months ago)
- Topics: publish, publish-subscribe, radio, receiver, subscriptions
- Language: Java
- Homepage:
- Size: 1.54 MB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
 [](https://jitpack.io/#Valkryst/VRadio)
# VRadio
A thread-safe implementation of the publish-subscribe pattern.
## Jar Files & Maven
To use this project as a Maven dependency, click on the JitPack badge [](https://jitpack.io/#Valkryst/VRadio), select a version, click the "Get it!" button, and then follow the instructions.
If you would rather use a Jar file, then you can find the Jars on the [releases](https://github.com/Valkryst/VRadio/releases) page.
## Examples
We'll be using the following Receiver class for all examples.
```java
public class TestReceiver implements Receiver {
private final String name;public TestReceiver(final String name) {
this.name = name;
}@Override
public void receive(final String event, final String data) {
System.out.println(name + " Received:");
System.out.println("\tEvent:\t" + event);
System.out.println("\tData:\t" + data);
}
}
```---
Construct a Radio and transmit an event with no data to the Receiver.
```java
final TestReceiver receiver = new TestReceiver("ReceiverA");
final Radio radio = new Radio<>();radio.addReceiver("EventA", receiver);
radio.transmit("EventA");
```---
Construct a Radio and transmit two different events to three different Receivers.
```java
final TestReceiver receiverA = new TestReceiver("ReceiverA");
final TestReceiver receiverB = new TestReceiver("ReceiverB");
final TestReceiver receiverC = new TestReceiver("ReceiverC");
final Radio radio = new Radio<>();radio.addReceiver("EventA", receiverA);
radio.addReceiver("EventB", receiverB);
radio.addReceiver("EventA", receiverC);
radio.addReceiver("EventB", receiverC);System.out.println("Transmitting EventA:");
radio.transmit("EventA", "DataA");System.out.println("\n\nTransmitting EventB:");
radio.transmit("EventB", "DataB");
```## JavaDoc Documentation:
Whenever a Travis CI build passes, the JavaDocs are auto-generated and made available at the following link.
https://valkryst.github.io/VRadio/.