Keventbus
Performance and thread-safe oriented eventbus
Install / Use
/learn @KevinPriv/KeventbusREADME
KEventBus
JVM Eventbus focused on thread-safety and performance.
Registering
Kotlin
// Create eventbus
private val eventBus = eventbus {
invoker { LMFInvoker() }
exceptionHandler { exception -> println("Error occurred in method: ${exception.message}") }
}
// Method you would like to subscribe to an event
// Param #1 is MessagedReceivedEvent therefore this method will be subscribed to that class
@Subscribe
fun `subscribed method`(event: MessageReceivedEvent) {
// do something
println(event.message)
}
...
// Register all the @Subscribe 'd methods inside of an instance
eventBus.register(this)
Java
// Create eventbus
private EventBus eventBus = new EventBus(new LMFInvoker(), e -> {
System.out.println("Error occurred in method: " + e.getMessage());
});
// Method you would like to subscribe to an event
// Param #1 is MessagedReceivedEvent therefore this method will be subscribed to that class
@Subscribe
public void subscribedMethod(MessageReceivedEvent event) {
System.out.println(event.getMessage());
}
...
// Register all the @Subscribe 'd methods inside of an instance
eventBus.register(this)
Posting
Kotlin
// Post all methods subscribed to the event `MessageReceivedEvent`
eventBus.post(MessageReceivedEvent("Hello world"))
Java
// Post all methods subscribed to the event `MessageReceivedEvent`
eventBus.post(new MessageReceivedEvent("Hello world"));
Unregistering
Kotlin
// Remove all @Subscribe 'd methods from an instance
eventBus.unregister(this)
Java
// Remove all @Subscribe 'd methods from an instance
eventBus.unregister(this)
Related Skills
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
