commonMain.ru.casperix.signals.collection.ObservableCollection.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signals Show documentation
Show all versions of signals Show documentation
Signals for all occasions
The newest version!
package ru.casperix.signals.collection
import ru.casperix.signals.concrete.Slot
import ru.casperix.signals.concrete.Future
interface ObservableCollection- : Collection
- {
fun addFuture(): Future
-
fun removeFuture(): Future
-
fun then(addListener: (Item) -> Unit, removeListener: (Item) -> Unit): Pair
{
return Pair(
addFuture().then(addListener),
removeFuture().then(removeListener)
)
}
fun cancel(forAdd: Slot?, forRemove: Slot?) {
forAdd?.let { addFuture().cancel(it) }
forRemove?.let { removeFuture().cancel(it) }
}
fun thenAdd(listener: (Item) -> Unit): Slot? {
return addFuture().then(listener)
}
fun thenRemove(listener: (Item) -> Unit): Slot? {
return removeFuture().then(listener)
}
}