aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/me/bush/eventbuskotlin/Config.kt
blob: bad5e79a7a0d5a8f37df1c8b92aeb1ac17640412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package me.bush.eventbuskotlin

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import org.apache.logging.log4j.Logger


/**
 * A class containing configuration options for an [EventBus].
 *
 * [Information and examples](https://github.com/therealbush/eventbus-kotlin#creating-an-eventbus)
 *
 * @author bush
 * @since 1.0.0
 */
data class Config(

    /**
     * The logger this [EventBus] will use to log errors, or [EventBus.debug]
     *
     * [Information and examples](https://github.com/therealbush/eventbus-kotlin#logger)
     */
    val logger: Logger = LOGGER,

    /**
     * The [CoroutineScope] to use when posting events to parallel listeners. The default
     * value will work just fine, but you can specify a custom scope if desired.
     *
     * [What is a Coroutine?](https://kotlinlang.org/docs/coroutines-overview.html)
     *
     * [Information and examples](https://github.com/therealbush/eventbus-kotlin#parallelScope)
     */
    val parallelScope: CoroutineScope = CoroutineScope(Dispatchers.Default),

    /**
     * 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#thirdpartyCompatibility)
     */
    val thirdPartyCompatibility: Boolean = true,

    /**
     * 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#annotationRequired)
     */
    val annotationRequired: Boolean = false
)