aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortherealbush <therealbush@users.noreply.github.com>2022-04-23 15:32:41 -0700
committertherealbush <therealbush@users.noreply.github.com>2022-04-23 15:32:41 -0700
commitadc29fb685307385cfa9ebb813ad2bfb18bb7776 (patch)
tree59b27215bb4c0db457f321d030fef9ba0c55b7fc
parentc12696bd528e891b9da126d3b92f3db089b4b6e6 (diff)
downloadeventbus-kotlin-adc29fb685307385cfa9ebb813ad2bfb18bb7776.tar.gz
eventbus-kotlin-adc29fb685307385cfa9ebb813ad2bfb18bb7776.tar.bz2
eventbus-kotlin-adc29fb685307385cfa9ebb813ad2bfb18bb7776.zip
updated links
-rw-r--r--README.md14
-rw-r--r--settings.gradle.kts2
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/CancelledState.kt6
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/Config.kt10
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/Event.kt8
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/EventBus.kt12
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/Listener.kt6
-rw-r--r--src/main/kotlin/me/bush/eventbuskotlin/Util.kt2
-rw-r--r--src/test/kotlin/KotlinTest.kt2
9 files changed, 28 insertions, 34 deletions
diff --git a/README.md b/README.md
index c196ba2..ad46aea 100644
--- a/README.md
+++ b/README.md
@@ -121,8 +121,8 @@ listener<EventType>(priority = 0, parallel = false, receiveCancelled = false) {
```java
listener(EventType.class,0,false,false,event->{
- ...listener body...
- });
+ ...listener body...
+});
```
Listeners can be registered either directly with `EventBus#register`, or subscribed by returning them from a function or
@@ -147,14 +147,14 @@ fun listener2() = listener<EventType> {
```java
public Listener listener0=listener(EventType.class,event->{
- ...listener body...
- });
+ ...listener body...
+});
public Listener listener1(){
- return listener(EventType.class,event->{
+ return listener(EventType.class,event->{
...listener body...
- });
- }
+ });
+}
```
#### priority
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 49d1d6a..34a4660 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,3 +1,3 @@
-rootProject.name = "illnamethislater"
+rootProject.name = "eventbuskotlin"
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/CancelledState.kt b/src/main/kotlin/me/bush/eventbuskotlin/CancelledState.kt
index 861b9fd..a0e01c0 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/CancelledState.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/CancelledState.kt
@@ -14,8 +14,6 @@ import kotlin.reflect.typeOf
/**
* A simple SAM interface for determining if an event (or any class) is cancellable.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
- *
* @author bush
* @since 1.0.0
*/
@@ -25,8 +23,6 @@ internal fun interface CancelledState {
* [event] should only ever be of the type that was passed
* to [CancelledState.invoke], **or this will throw.**
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
- *
* @return `true` if [event] is cancelled, `false` otherwise.
*/
fun isCancelled(event: Any): Boolean
@@ -43,8 +39,6 @@ internal fun interface CancelledState {
/**
* Creates a [CancelledState] object for events of class [type].
- *
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
*/
operator fun invoke(type: KClass<*>, config: Config): CancelledState = CACHE.getOrPut(type) {
// Default implementation for our event class.
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/Config.kt b/src/main/kotlin/me/bush/eventbuskotlin/Config.kt
index f0e1120..bad5e79 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/Config.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/Config.kt
@@ -8,7 +8,7 @@ import org.apache.logging.log4j.Logger
/**
* A class containing configuration options for an [EventBus].
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-eventbus)
*
* @author bush
* @since 1.0.0
@@ -18,7 +18,7 @@ data class Config(
/**
* The logger this [EventBus] will use to log errors, or [EventBus.debug]
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#logger)
*/
val logger: Logger = LOGGER,
@@ -28,7 +28,7 @@ data class Config(
*
* [What is a Coroutine?](https://kotlinlang.org/docs/coroutines-overview.html)
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#parallelScope)
*/
val parallelScope: CoroutineScope = CoroutineScope(Dispatchers.Default),
@@ -36,7 +36,7 @@ data class Config(
* Whether this [EventBus] should try to find a "cancelled" field in events being listened for that
* are not a subclass of [Event]. This is experimental, and should be set to `false` if problems arise.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#thirdpartyCompatibility)
*/
val thirdPartyCompatibility: Boolean = true,
@@ -44,7 +44,7 @@ data class Config(
* Whether listeners need to be annotated with [EventListener] to be subscribed to this [EventBus].
* This has no effect on anything else, and is just to improve code readability.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#annotationRequired)
*/
val annotationRequired: Boolean = false
)
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/Event.kt b/src/main/kotlin/me/bush/eventbuskotlin/Event.kt
index 50f1131..6b96461 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/Event.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/Event.kt
@@ -3,7 +3,7 @@ package me.bush.eventbuskotlin
/**
* A base class for events that can be cancelled.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#ththingtodo)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-event)
*
* @author bush
* @since 1.0.0
@@ -15,7 +15,7 @@ abstract class Event {
* [Listener.receiveCancelled] will receive it. However, it can be set back to
* `false`, and listeners will be able to receive it again.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#posting-an-event)
*/
var cancelled = false
set(value) {
@@ -25,14 +25,14 @@ abstract class Event {
/**
* Determines if this event can be [cancelled]. This does not have to return a constant value.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-event)
*/
protected abstract val cancellable: Boolean
/**
* Sets [cancelled] to true.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#posting-an-event)
*/
fun cancel() {
cancelled = true
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/EventBus.kt b/src/main/kotlin/me/bush/eventbuskotlin/EventBus.kt
index eeb887d..e08ef14 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/EventBus.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/EventBus.kt
@@ -21,7 +21,7 @@ class EventBus(private val config: Config = Config()) {
*
* This will not find top level members, use [register] instead.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#subscribing-an-object)
*
* @return `true` if [subscriber] was successfully subscribed,
* `false` if it was already subscribed, or could not be.
@@ -37,7 +37,7 @@ class EventBus(private val config: Config = Config()) {
*
* This will not remove top level listeners, use [unregister] instead.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#subscribing-an-object)
*
* @return `true` if [subscriber] was successfully unsubscribed, `false` if it was not subscribed.
*/
@@ -48,7 +48,7 @@ class EventBus(private val config: Config = Config()) {
/**
* Registers a [Listener] to this [EventBus].
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-a-listener)
*/
fun register(listener: Listener): Boolean = listeners.computeIfAbsent(listener.type) {
ListenerGroup(it, config)
@@ -57,7 +57,7 @@ class EventBus(private val config: Config = Config()) {
/**
* Unregisters a [Listener] from this [EventBus]. Returns `true` if [Listener] was registered.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-a-listener)
*/
fun unregister(listener: Listener): Boolean = listeners[listener.type]?.let {
val contained = it.unregister(listener)
@@ -80,7 +80,7 @@ class EventBus(private val config: Config = Config()) {
* Sequential listeners are called in the order of [Listener.priority], and parallel listeners
* are called after using [launch]. This method will not wait for parallel listeners to complete.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#posting-an-event)
*/
fun post(event: Any): Boolean = listeners[event::class]?.post(event) ?: false
@@ -90,7 +90,7 @@ class EventBus(private val config: Config = Config()) {
*
* **This may cause a [ConcurrentModificationException] if [register] or [subscribe] is called in parallel.**
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin)
* ```
* Subscribers: 5
* Listeners: 8 sequential, 21 parallel
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/Listener.kt b/src/main/kotlin/me/bush/eventbuskotlin/Listener.kt
index bb78b75..7f92211 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/Listener.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/Listener.kt
@@ -7,7 +7,7 @@ import kotlin.reflect.KClass
* This class is not intended to be used externally, use [listener] instead. You *could* use this,
* and it would work fine however you would have to specify the type explicitly. (ew!)
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-event)
*
* @author bush
* @since 1.0.0
@@ -30,7 +30,7 @@ class Listener @PublishedApi internal constructor(
* or getter belonging to an object to be subscribed with [EventBus.subscribe],
* or directly registered to an [EventBus] with [EventBus.register].
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-event)
*
* @param T The **exact** (no inheritance) type of event to listen for.
* @param priority The priority of this listener, high to low.
@@ -52,7 +52,7 @@ inline fun <reified T : Any> listener(
* or getter belonging to an object to be subscribed with [EventBus.subscribe],
* or directly registered to an [EventBus] with [EventBus.register].
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-event)
*
* @param type The **exact** (no inheritance) type of event to listen for.
* @param priority The priority of this listener, high to low.
diff --git a/src/main/kotlin/me/bush/eventbuskotlin/Util.kt b/src/main/kotlin/me/bush/eventbuskotlin/Util.kt
index edad824..f576f4c 100644
--- a/src/main/kotlin/me/bush/eventbuskotlin/Util.kt
+++ b/src/main/kotlin/me/bush/eventbuskotlin/Util.kt
@@ -72,6 +72,6 @@ internal fun getListeners(subscriber: Any, config: Config) = runCatching {
/**
* An annotation that must be used to identify listeners if [Config.annotationRequired] is `true`.
*
- * [Information and examples](https://github.com/therealbush/eventbus-kotlin#tododothething)
+ * [Information and examples](https://github.com/therealbush/eventbus-kotlin#annotationRequired)
*/
annotation class EventListener
diff --git a/src/test/kotlin/KotlinTest.kt b/src/test/kotlin/KotlinTest.kt
index 136e7c8..cddf538 100644
--- a/src/test/kotlin/KotlinTest.kt
+++ b/src/test/kotlin/KotlinTest.kt
@@ -235,7 +235,7 @@ class KotlinTest {
eventBus.unsubscribe(this)
}
- var called = false
+ private var called = false
@EventListener
val annotation = listener<Unit> {