package ocelot.desktop.util /** * Keeps a reference to an object * and tells whether there were any changes to the value since the last check. */ class Watcher[T](value: T) { private var hash: Int = value.hashCode() def didChange: Boolean = { val newHash = value.hashCode() if (hash != newHash) { hash = newHash true } else { false } } } object Watcher { def apply[T](value: T) = new Watcher(value) }