ObservableState.kt 428 Bytes
package application.model

import kotlin.properties.Delegates

class ObservableState {
    val listeners: MutableList<StateListener> = mutableListOf()

    var state: State by Delegates.observable(
        initialValue = State.CLUSTERED_MESSAGES,
        onChange = { _, _, new ->
            run {
                listeners.forEach {
                    it.onValueChanged(new)
                }
            }
        }
    )
}