ListenerPreparer

监听准备。

由 boot 模块所提供,通过注解 love.forte.simboot.annotation.Preparer 解析到目标监听函数中。

ListenerPreparer 概念与 AnnotatedEventListenerInterceptor 类似,但是 ListenerPreparer单点插入的形式, 且无法进行 拦截 操作,仅适用于一些数据的准备工作(例如在 EventListener.match 执行前对 EventListenerProcessingContext.textContent 做出调整)。

通常情况下 ListenerPreparer 不能也不应该对监听函数的流程造成硬影响,且准备工作应当是迅速的。在实现时需尽可能避免异常的产生和长时间的操作。

顺序

ListenerPreparer 直接作用于监听函数上,因此 ListenerPreparer 的执行将始终晚于全局性的 监听拦截器pointAFTER_MATCH 的全局函数拦截器除外, prepareMatch 将会早于这些拦截器 ),且优先于 AnnotatedEventListenerInterceptor.


对于不支持挂起函数的实现方,使用 BlockingListenerPreparer

Author

ForteScarlet

See also

Functions

Link copied to clipboard
abstract suspend fun prepareInvoke(context: EventListenerProcessingContext)

EventListener.invoke 前执行准备。

Link copied to clipboard
abstract suspend fun prepareMatch(context: EventListenerProcessingContext)

EventListener.match 前执行准备。

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard