jvmMain.io.nacular.doodle.utils.Observables.kt Maven / Gradle / Ivy
package io.nacular.doodle.utils
import java.util.concurrent.CopyOnWriteArraySet
/**
* Created by Nicholas Eddy on 7/22/21.
*/
public actual open class SetPool actual constructor(protected actual val delegate: MutableSet): Pool, Set by delegate {
public actual constructor(): this(CopyOnWriteArraySet())
override fun plusAssign (item: T) { delegate += item }
override fun minusAssign(item: T) { delegate -= item }
}
public actual class ChangeObserversImpl actual constructor(private val source: S, mutableSet: MutableSet>): SetPool>(mutableSet) {
public actual constructor(source: S): this(source, CopyOnWriteArraySet())
public actual operator fun invoke(): Unit = delegate.forEach { it(source) }
}
public actual class PropertyObserversImpl actual constructor(private val source: S, mutableSet: MutableSet>): SetPool>(mutableSet) {
public actual constructor(source: S): this(source, CopyOnWriteArraySet())
public actual operator fun invoke(old: T, new: T): Unit = delegate.forEach { it(source, old, new) }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy