org.hnau.emitter.observing.push.PushEmitter.kt Maven / Gradle / Ivy
package org.hnau.emitter.observing.push
import org.hnau.emitter.observing.ObservingEmitter
abstract class PushEmitter : ObservingEmitter() {
companion object {
fun create(
tryGetValue: (onValue: (T) -> Unit) -> Unit
) = object : PushEmitter() {
override fun tryGetValue(onValue: (T) -> Unit) = tryGetValue(onValue)
}
}
protected abstract fun tryGetValue(onValue: (T) -> Unit)
protected open fun onChanged() =
tryGetValue(this::call)
override fun onAttached(observer: (T) -> Unit) {
super.onAttached(observer)
tryGetValue(observer)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy