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

commonMain.ru.casperix.signals.concrete.Signal.kt Maven / Gradle / Ivy

The newest version!
package ru.casperix.signals.concrete

import ru.casperix.signals.api.AbstractSignal

/**
 * 	При срабатывании разово уведомляет всех подписчиков
 */
class Signal() : Promise, AbstractSignal<(Event) -> Unit, Slot>(SlotCollection()) {
	override fun set(value: Event) {
		forEach { listener ->
			listener(value)

		}
	}

	companion object {
		fun  pipe(vararg initiatorList: Future): Future {
			val signal = Signal()
			initiatorList.forEach { initiator ->
				initiator.then { event ->
					signal.set(event)
				}
			}
			return signal
		}
	}
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy