package com.adealink.weparty.room.micseat

import androidx.annotation.CallSuper
import com.adealink.frame.mvvm.viewmodel.BaseViewModel
import com.adealink.weparty.room.micseat.viewmodel.IRoomSeatViewModel
import com.adealink.weparty.room.sdk.listener.ISeatListener
import com.adealink.weparty.room.sdk.service.roomService
import kotlinx.coroutines.launch

abstract class BaseSeatsTemplateViewModel : BaseViewModel(), IRoomSeatViewModel, ISeatListener {

    val seatController by lazy { roomService.seatController }

    init {
        seatController.addListener(this)
    }

    override fun getMicSeatsInfo() {
        viewModelScope.launch {
            seatController.getMicSeatsInfo()
        }
    }


    @CallSuper
    override fun onCleared() {
        super.onCleared()
        seatController.removeListener(this)
    }
}