Changes to behaviour
This commit is contained in:
parent
58e3766ebd
commit
e1df66f994
@ -29,6 +29,14 @@ inline fun <reified T: Event> List<Event>.findFirstEventOf(): T? {
|
||||
} else null
|
||||
}
|
||||
|
||||
fun Event.isOfEvent(eventType: Events): Boolean {
|
||||
return this.eventType == eventType
|
||||
}
|
||||
|
||||
inline fun <reified T: Event> List<Event>.findEventOf(): T? {
|
||||
return this.filterIsInstance<T>().firstOrNull()
|
||||
}
|
||||
|
||||
inline fun List<Event>.findFirstOf(events: Events): Event? {
|
||||
return this.firstOrNull { it.eventType == events }
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package no.iktdev.eventi.core
|
||||
|
||||
import com.mysql.cj.protocol.Protocol.ProtocolEventListener.EventType
|
||||
import no.iktdev.eventi.data.EventImpl
|
||||
import no.iktdev.eventi.data.EventMetadata
|
||||
|
||||
@ -13,6 +14,10 @@ class ConsumableEvent<T: EventImpl>(private var event: T) {
|
||||
} else null
|
||||
}
|
||||
|
||||
fun isOfEvent(eventType: Any): Boolean {
|
||||
return event.eventType == eventType
|
||||
}
|
||||
|
||||
fun metadata(): EventMetadata {
|
||||
return event.metadata
|
||||
}
|
||||
|
||||
@ -66,6 +66,9 @@ abstract class EventListenerImpl<T: EventImpl, E: EventsManagerImpl<T>> {
|
||||
}
|
||||
|
||||
open fun shouldIProcessAndHandleEvent(incomingEvent: T, events: List<T>): Boolean {
|
||||
if (listensForEvents.isEmpty()) {
|
||||
return true
|
||||
}
|
||||
if (!isOfEventsIListenFor(incomingEvent))
|
||||
return false
|
||||
if (!isPrerequisitesFulfilled(incomingEvent, events)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user