summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-05 21:08:00 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-10 13:17:02 +0000
commit2ed16ea24d51633641e6275115144c4de9585a21 (patch)
treea12c0e1c19ba27910e363cf0883b0ab85649490f
parent71a7b7abf7ec3584e41c251bc7d22c61850a47af (diff)
downloadmullvadvpn-2ed16ea24d51633641e6275115144c4de9585a21.tar.xz
mullvadvpn-2ed16ea24d51633641e6275115144c4de9585a21.zip
Create `EventNotifier.notifiable()` prop. delegate
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt6
1 files changed, 6 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt b/android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt
index bcd27820b8..395146b168 100644
--- a/android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt
+++ b/android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt
@@ -1,5 +1,7 @@
package net.mullvad.talpid.util
+import kotlin.properties.Delegates.observable
+
// Manages listeners interested in receiving events of type T
//
// The listeners subscribe using an ID object. This ID is used later on for unsubscribing. The only
@@ -47,4 +49,8 @@ class EventNotifier<T>(private val initialValue: T) {
listeners.clear()
}
}
+
+ fun notifiable() = observable(latestEvent) { _, _, newValue ->
+ notify(newValue)
+ }
}