package com.example.defenseapplication.utils

object FamilySwitchEvent {
    private val listeners = mutableListOf<FamilySwitchListener>()

    interface FamilySwitchListener {
        fun onFamilySwitched(familyName: String)
    }

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

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

    fun notifyFamilySwitched(familyName: String) {
        listeners.forEach { it.onFamilySwitched(familyName) }
    }
}