Skip to content

Instantly share code, notes, and snippets.

View zeruth's full-sized avatar

Tyler Bochard zeruth

View GitHub Profile
@zeruth
zeruth / EventBus.kt
Created May 11, 2025 05:57
Simple, and powerful Kotlin EventBus
import kotlin.reflect.KClass
data class Subscription<T : Any>(val type: KClass<T>, val priority: Int, val unit: (Any) -> Unit)
object EventBus {
var subscriptions = ArrayList<Subscription<*>>()
@Suppress("UNCHECKED_CAST")
inline fun <reified T : Any> subscribe(priority: Int = 0, noinline unit: (T) -> Unit) {
subscriptions += Subscription(T::class, priority, unit as (Any) -> Unit)
Computer Information:
Manufacturer: ASUS
Model: All Series
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
CPU Family: 0x6