diff --git a/gradle.properties b/gradle.properties index 9dde8ab..01a38b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ kotlin.code.style=official specifyKotlinAsDependency=false projectGroup=ru.dbotthepony.kommons -projectVersion=2.9.9 +projectVersion=2.9.10 guavaDepVersion=33.0.0 gsonDepVersion=2.8.9 diff --git a/src/main/kotlin/ru/dbotthepony/kommons/io/DelegateSyncher.kt b/src/main/kotlin/ru/dbotthepony/kommons/io/DelegateSyncher.kt index a182fa1..d9e5735 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/io/DelegateSyncher.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/io/DelegateSyncher.kt @@ -41,6 +41,7 @@ import kotlin.concurrent.withLock * Attached delegates can be safely mutated by multiple threads concurrently * (attached [ListenableDelegate] can call [Listenable.addListener] callback concurrently). */ +@Suppress("UNCHECKED_CAST", "UNUSED") class DelegateSyncher : Observer { private val lock = ReentrantLock() private val slots = ArrayList() @@ -283,6 +284,10 @@ class DelegateSyncher : Observer { it.changelist.add(SetAction(KOptional(), CLEAR)) } + listeners.forEach { + it.listener.onClear() + } + it.markDirty() } } @@ -296,6 +301,10 @@ class DelegateSyncher : Observer { it.changelist.add(SetAction(KOptional(codec.copy(element)), ADD)) } + listeners.forEach { + it.listener.onValueAdded(element) + } + it.markDirty() } } @@ -309,6 +318,10 @@ class DelegateSyncher : Observer { it.changelist.add(SetAction(KOptional(codec.copy(element)), REMOVE)) } + listeners.forEach { + it.listener.onValueRemoved(element) + } + it.markDirty() } } @@ -387,6 +400,10 @@ class DelegateSyncher : Observer { it.changelist.add(MapAction(KOptional(), KOptional(), CLEAR)) } + listeners.forEach { + it.listener.onClear() + } + it.markDirty() } } @@ -400,6 +417,10 @@ class DelegateSyncher : Observer { it.changelist.add(MapAction(KOptional(keyCodec.copy(key)), KOptional(valueCodec.copy(value)), ADD)) } + listeners.forEach { + it.listener.onValueAdded(key, value) + } + it.markDirty() } } @@ -413,6 +434,10 @@ class DelegateSyncher : Observer { it.changelist.add(MapAction(KOptional(keyCodec.copy(key)), KOptional(), REMOVE)) } + listeners.forEach { + it.listener.onValueRemoved(key, value) + } + it.markDirty() } }