SafeListeners

Helper class to manager callback handlers

The class supports add\remove listeners during forEach, preventing ConcurrentModificationException

Note: the class is NOT thread safe

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun add(listener: T)

Add a listener to the pull

Link copied to clipboard
fun clear()

Remove all listeners

Link copied to clipboard
fun forEach(execute: (listener: T) -> Unit)

iterate over the listeners

Link copied to clipboard
fun forEachIfUnlocked(execute: (listener: T) -> Unit)

iterate over the listeners only if isLocked is false.

Link copied to clipboard
fun remove(listener: T)

Remove a listener from the pull

Link copied to clipboard
fun size(): Int

Return the number of listeners