Skip to content

Commit

Permalink
Guard against subscribing more than once to event listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
murki committed Dec 19, 2024
1 parent 77f81aa commit 6106dcb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package io.bitdrift.capture.events.lifecycle

import io.bitdrift.capture.IEventsListenerTarget
import io.bitdrift.capture.events.IEventListenerLogger
import io.bitdrift.capture.events.SafeEventListenerLogger

/**
* A wrapper around platform event listeners that subscribe to various system notifications
Expand All @@ -18,7 +19,7 @@ internal class EventsListenerTarget : IEventsListenerTarget {
private var listeners: MutableList<IEventListenerLogger> = mutableListOf()

fun add(eventListener: IEventListenerLogger) {
listeners.add(eventListener)
listeners.add(SafeEventListenerLogger(eventListener))
}
override fun start() {
listeners.forEach { it.start() }
Expand Down

0 comments on commit 6106dcb

Please sign in to comment.