mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
parent
5dfc08aabb
commit
5af1b80cb7
1 changed files with 12 additions and 6 deletions
|
@ -6,15 +6,21 @@ class Event<T> {
|
|||
val size: Int get() = observers.size
|
||||
|
||||
operator fun plusAssign(observer: (T) -> Unit) {
|
||||
synchronized(observers) {
|
||||
observers.add(observer)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun minusAssign(observer: (T) -> Unit) {
|
||||
synchronized(observers) {
|
||||
observers.remove(observer)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun invoke(value: T) {
|
||||
synchronized(observers) {
|
||||
for (observer in observers)
|
||||
observer(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue