Skip to content

Instantly share code, notes, and snippets.

@s4cha
s4cha / Notifier.kt
Last active June 20, 2019 14:58
EventBus in Kotlin under 50 lines \o/
import kotlinx.coroutines.*
typealias Callback<T> = (T) -> Unit
class CallbackWrapper<T>(val callback:Callback<T>, val eventName: String, val receiverHash: Int, val dispatcher: CoroutineDispatcher)
object Notifier: CoroutineScope {
private val supervisorJob = SupervisorJob()