
commonMain.viewmodel.IntentBus.kt Maven / Gradle / Ivy
package viewmodel
import koncurrent.Executor
import koncurrent.SynchronousExecutor
import live.*
import kotlin.jvm.JvmOverloads
open class IntentBus @JvmOverloads constructor(val executor: Executor = SynchronousExecutor) {
private val INTENT = mutableLiveOf(null)
fun post(i: I) {
INTENT.value = i
}
fun onIntent(callback: (I) -> Unit): Watcher = INTENT.watch(WatchMode.Casually, executor) {
if (it != null) callback(it)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy