FunctionalBindableEventListener

可以进行动态参数绑定的 FunctionalEventListener, 可以通过 binderscaller 进行参数绑定。

invoke 中,如果 caller 是可挂起的(isSuspend = true), 则通过可挂起执行。 如果不是可挂起的,则会通过 runWithInterruptible 在可中断中普通执行。 runWithInterruptible 默认情况下会使用 Dispatchers.IO 作为默认调度器。

Constructors

Link copied to clipboard
constructor(matcher: suspend (EventListenerProcessingContext) -> Boolean, caller: KFunction<R>)

Properties

Link copied to clipboard
protected abstract val binders: Array<ParameterBinder>

binder数组,其索引下标应当与 KCallable.parametersKParameter.index 相对应。 在使用 binders 时,会直接按照其顺序转化为对应的值。

Link copied to clipboard
override val caller: KFunction<R>

当前监听函数所对应的执行器。

Functions

Link copied to clipboard
protected open fun convertValue(value: Any?, parameter: KParameter): Any?

对结果的数据类型进行转化。

Link copied to clipboard
abstract override fun <T : Any> getAttribute(attribute: Attribute<T>): T?
Link copied to clipboard
open suspend operator override fun invoke(context: EventListenerProcessingContext): EventResult

函数执行。

Link copied to clipboard
abstract override fun isTarget(eventType: Event.Key<*>): Boolean
Link copied to clipboard
open suspend override fun match(context: EventListenerProcessingContext): Boolean
Link copied to clipboard
protected open suspend fun resultProcess(result: R): EventResult

caller 执行后的返回值进行处理并转化为 EventResult. 可覆盖并自定义结果逻辑。