package com.example.quiz.viewModel;

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

import com.example.quiz.data.model.Reunion;
import com.example.quiz.data.repository.ReunionRepository;
import com.example.quiz.utils.Result;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class ReunionViewModel extends ViewModel {
    private final ReunionRepository reunionRepository;

    private LiveData<Result<List<Reunion>>> reunions;

    @Inject
    public ReunionViewModel(ReunionRepository reunionRepository) {
        this.reunionRepository = reunionRepository;
    }

    public LiveData<Result<List<Reunion>>> getReunions(String date) {
        if (reunions == null) {
            reunions = reunionRepository.getReunions(date);
        }
        return reunions;
    }
}
