Event Dispatcher
事件调度器。 EventDispatcher 拥有 EventProcessor 和 EventListenerRegistrar 的职责, 是对事件调度、事件监听器管理的统一单元。
Author
ForteScarlet
Properties
Link copied to clipboard
得到当前容器内所有的 EventListener 的序列。 如无特殊说明则会按照优先级顺序获取。
Functions
Link copied to clipboard
注销所有通过指定的 EventListener 所注册的事件处理器。
Link copied to clipboard
inline fun <E : Event> EventListenerRegistrar.listen(propertiesConsumer: ConfigurerFunction<EventListenerRegistrationProperties>? = null, crossinline defaultResult: EventListenerContext.() -> EventResult = { EventResult.invalid }, crossinline listenerFunction: suspend EventListenerContext.(E) -> EventResult)
为特定事件类型注册事件处理器函数。
Link copied to clipboard
推送一个事件, 得到内部所有事件依次将其处理后得到最终的结果流。
Link copied to clipboard
推送事件并将结果转化为 Flux. 需要项目环境中存在 kotlinx-coroutines-reactor 依赖。
Link copied to clipboard
suspend fun EventProcessor.pushAndCollect(event: Event, collector: FlowCollector<EventResult>? = null)
将事件推送并收集处理。
Link copied to clipboard
fun <C : MutableCollection<in EventResult>> EventProcessor.pushAndCollectToAsync(event: Event, scope: CoroutineScope, collection: C): CompletableFuture<C>
推送事件并将结果收集为 C 后返回 CompletableFuture.
Link copied to clipboard
fun EventProcessor.pushAndCollectToListAsync(event: Event, scope: CoroutineScope): CompletableFuture<out List<EventResult>>
推送事件并将结果收集为 List 后返回 CompletableFuture.
Link copied to clipboard
通过 scope 将事件推送并异步处理,不关心事件的结果。
Link copied to clipboard
fun EventProcessor.pushAndLaunch(scope: CoroutineScope, event: Event, collector: FlowCollector<EventResult>? = null): Job
将事件推送并异步处理。
Link copied to clipboard
inline fun EventProcessor.pushAndLaunchThen(scope: CoroutineScope, event: Event, crossinline useFlow: (Flow<EventResult>) -> Unit): Job
将事件推送并异步处理。
Link copied to clipboard
注册一个默认属性的 EventListener.
abstract fun register(propertiesConsumer: ConfigurerFunction<EventListenerRegistrationProperties>?, listener: EventListener): EventListenerRegistrationHandle
注册一个 EventListener 并附加部分额外属性信息。