commonMain.ru.casperix.signals.functor.FunctorCollection.kt Maven / Gradle / Ivy
package ru.casperix.signals.functor
import ru.casperix.signals.api.CustomSlotCollection
class FunctorCollection, Event> : CustomSlotCollection {
private val listeners = mutableSetOf()
override fun cancel(slot: Listener): Boolean {
return listeners.remove(slot)
}
override fun getListener(slot: Listener): Listener? {
return listeners.firstOrNull { it == slot }
}
override fun removeAllListeners() {
listeners.clear()
}
override fun then(listener: Listener): Listener {
listeners.add(listener)
return listener
}
override val size: Int
get() = listeners.size
override fun forEach(action: (Listener) -> Unit) {
listeners.forEach(action)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy