summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-22 14:56:19 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-25 11:51:59 +0000
commit8557e5aa95f06c1d6ebea6eae7631a024a482260 (patch)
tree6bfc97f249a5d9df3a121d28f68ab7c6ddb555ee /android/src
parent45d1f2afcde9175039788354acc9a6b908cca153 (diff)
downloadmullvadvpn-8557e5aa95f06c1d6ebea6eae7631a024a482260.tar.xz
mullvadvpn-8557e5aa95f06c1d6ebea6eae7631a024a482260.zip
Document `EventNotifier`'s object ID usage risks
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/util/EventNotifier.kt8
1 files changed, 8 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 13d9fecc14..27d0d9ac05 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,13 @@
package net.mullvad.talpid.util
+// 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
+// requirement is that the object uses the default implementation of the `hashCode` and `equals`
+// methods inherited from `Any` (or `Object` in Java).
+//
+// If the ID object class (or any of its super-classes) overrides `hashCode` or `equals`,
+// unsubscribe might not work correctly.
class EventNotifier<T>(private val initialValue: T) {
private val listeners = HashMap<Any, (T) -> Unit>()