coder-bee / recipe-lovers-club

Vegan Lovers Club is an Open Source Android Project to help members find co-learners and mentors at a given period/slot.
https://www.notion.so/samsaaraa/Vegan-Lovers-Club-664e821868534212afa84bb5b3fda373
8 stars 4 forks source link

Create RecipeListViewModel #6

Open droidizer opened 1 year ago

Ben-ayesu commented 1 year ago

`class MealsScreenViewModel (private val repository: Mealsrepo = Mealsrepo()): ViewModel(){

init {
    viewModelScope.launch(Dispatchers.IO) {
        val meal = getMeals()
        mealState.value = meal
    }
}
val mealState = mutableStateOf(emptyList<MealResponse>())

private suspend fun getMeals(): List<MealResponse> {
    return repository.getMeals().categories
}

}`