package com.example.defenseapplication.utils

object DeviceUpdateEvent {
    private val listeners = mutableListOf<DeviceUpdateListener>()

    interface DeviceUpdateListener {
        fun onDeviceUpdated(deviceId: String)
    }

    fun addListener(listener: DeviceUpdateListener) {
        if (!listeners.contains(listener)) {
            listeners.add(listener)
        }
    }

    fun removeListener(listener: DeviceUpdateListener) {
        listeners.remove(listener)
    }

    fun notifyDeviceUpdated(deviceId: String) {
        listeners.forEach { it.onDeviceUpdated(deviceId) }
    }
}