ObservableVessel.kt 473 Bytes
package application.model

import java.util.*
import kotlin.properties.Delegates

class ObservableVessel {
    val listeners: MutableList<MessageListener> = mutableListOf()

    var vessels: MutableMap<Int?, Vessel> by Delegates.observable(
        initialValue = mutableMapOf(),
        onChange = {
            _, _, new ->
            run {
                listeners.forEach {
                    it.onValueChanged(new)
                }
            }
        }
    )

}