This commit introduces `ClusterViewModel` to manage the state and logic for fetching growth recipe recommendations.
Key functionalities:
- Manages a `StateFlow` named `_state` to represent the current state of the recommendation request (Idle, Loading, Success, Error).
- Provides a public `state` flow for observing changes in the recommendation request.
- Implements a `getRecommendation()` function that:
- Sets the state to `Loading`.
- Calls the `getRecommendation()` method of the `ClusteringRepository`.
- If successful and data is present, updates the state to `Success` with the last item from the response.
- If the response is empty, updates the state to `Error` with a "Data tidak ditemukan" message.
- Catches exceptions, maps them to user-friendly error messages, and updates the state to `Error`.
- Logs detailed error messages if fetching data fails.
|
||
|---|---|---|
| .. | ||
| .idea | ||
| .kotlin/errors | ||
| app | ||
| commodity_price_prediction_feature | ||
| control_feature | ||
| gradle | ||
| growth_recipe_feature | ||
| plant_disease_detection_feature | ||
| .gitignore | ||
| agrilinkvocpro-keystore.jks | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| settings.gradle.kts | ||