All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hnau.emitter.observing.push.PushEmitter.kt Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
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