blob: 476a34ac967f583e61276afc4f668d8eb9500f2b (
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
|
package me.bush.illnamethislater
/**
* A base class for events that can be cancelled.
*
* [Information and examples](https://github.com/therealbush/eventbus-kotlin#ththingtodo)
*
* @author bush
* @since 1.0.0
*/
abstract class Event {
/**
* Whether this event is cancelled or not. If it is, only future listeners with
* [Listener.receiveCancelled] will receive it. However, it can be set back to
* `false`, and listeners will be able to receive it again.
*/
var cancelled = false
set(value) {
if (cancellable) field = value
}
/**
* Determines if this event can be [cancelled]. This does not have to return a constant value.
*/
abstract val cancellable: Boolean
/**
* Sets [cancelled] to true.
*/
fun cancel() {
cancelled = true
}
}
|