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.
|
||
|---|---|---|
| .. | ||
| src | ||
| .gitignore | ||
| build.gradle.kts | ||