All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.ru.casperix.signals.functor.FunctorCollection.kt Maven / Gradle / Ivy

There is a newer version: 1.8.2
Show newest version
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