tipsy
10/31/2019, 6:19 PMprivate fun changeListener(obj: Any) {
fun getObjectString(): String {
val baos = ByteArrayOutputStream()
ObjectOutputStream(baos).also { it.writeObject(obj) }.also { it.close() }
return baos.toString()
}
var oldValue = getObjectString()
Thread {
while (true) {
val newValue = getObjectString()
if (oldValue != newValue) {
println("Change detected")
oldValue = newValue
}
Thread.sleep(250)
}
}.start()
}
furkan.akdemir
11/01/2019, 9:41 PMDelegates.observable()
var name: String by Delegates.observable(_name) { _, oldName, newName ->
println("Changed from $oldName to $newName")
_name = newName
}
tipsy
11/01/2019, 11:39 PMMyObject myObject = ...
i have access to myObject
and want to know if it changesDominaezzz
11/02/2019, 2:24 PMObjectOutputStream(baos).also { it.writeObject(obj) }.also { it.close() }
-> ObjectOutputStream(baos).use { it.writeObject(obj) }
.