Skip to content

feat(search): Add SearchViewModel and Logic

AGHARAHIMOV AGHASALIM requested to merge feature/search-viewmodel into main

What does this MR do?

This MR builds the complete "brain" for the movie search feature by implementing the SearchViewModel. It acts as the bridge between the future search UI and the existing MovieRepository.

Key Contributions:

  • SearchViewModel: Contains the core logic for executing a movie search. It includes a 500ms debounce to provide a better user experience and conserve API resources.
  • SearchUiState: A sealed class that models the screen's state, making the UI easier to manage and update predictably.
  • ViewModelFactory Refactor: The factory is now more robust and scalable. It uses the application Context to create dependencies (like the UserDao), simplifying the logic within the Fragments.
  • Unit Tests: The ViewModel is fully unit-tested to ensure its state management and interaction with the repository are correct.

Why was this change needed?

This is the final piece of the logic layer for the search feature. With this ViewModel merged, the UI developer can now simply connect the SearchFragment to it to create a fully functional end-to-end movie search experience. This completes the MVVM loop for this feature.

Merge request reports