package com.bearya.kids.analysis

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.switchMap
import androidx.paging.PagedList
import com.bearya.data.entity.Analysis
import com.bearya.data.entity.Chapter
import com.bearya.data.repository.AnalysisRepository
import com.bearya.data.repository.ChapterRepository
import library.ext.toLiveData

class AnalysisViewModel : ViewModel() {

    private val repository: AnalysisRepository by lazy { AnalysisRepository() }

    val sectionId : MutableLiveData<Int> by lazy { MutableLiveData<Int>() }

    val analysis: LiveData<PagedList<Analysis>>  = sectionId.switchMap {
        repository.findAnalysisBySectionId(it).toLiveData()
    }

}