package com.example.quiz.viewModel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;

import com.example.quiz.data.model.Course;
import com.example.quiz.data.repository.CourseRepository;
import com.example.quiz.utils.Result;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class CourseViewModel extends ViewModel {
    private final CourseRepository courseRepository;

    private LiveData<Result<List<Course>>> courses;

    @Inject
    public CourseViewModel(CourseRepository courseRepository){
        this.courseRepository = courseRepository;
    }

    public LiveData<Result<List<Course>>> getCourses(String reunionId){
        if(courses == null){
            courses = courseRepository.getCourses(reunionId);
        }
        return courses;
    }
}
