package cn.yyxx.eyuangame.core.linking

import android.content.Context
import cn.yyxx.eyuangame.core.internal.IEventObserver
import cn.yyxx.eyuangame.core.linking.channel.LinkingAdjustImpl
import cn.yyxx.eyuangame.core.linking.channel.LinkingFirebaseImpl

/**
 * @author #Suyghur.
 * Created on 2021/06/17
 */
class Linking {

    private val observers: MutableList<IEventObserver> = mutableListOf()

    fun attach(context: Context) {
        observers.add(LinkingAdjustImpl())
        observers.add(LinkingFirebaseImpl())
    }

    fun detach() {
        if (!observers.isNullOrEmpty()) {
            observers.clear()
        }
    }


    companion object {
        val instance: Linking by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            Linking()
        }
    }
}