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
|
@ -3,18 +3,24 @@ package com.lagradost.cloudstream3.utils
|
|||
class Event<T> {
|
||||
private val observers = mutableSetOf<(T) -> Unit>()
|
||||
|
||||
val size : Int get() = observers.size
|
||||
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