Use Case (hay Interactor) đóng gói một thao tác business logic duy nhất, nhận input và trả về output.
Ví dụ: LoginUseCase, FetchUserDataUseCase. Use Case là phần của Domain layer trong Clean Architecture và độc lập với UI framework. Chúng giúp logic tái sử dụng được, test được, và dễ hiểu. Tạo Use Case khi một logic cần được dùng từ nhiều ViewModel hoặc cần test độc lập.
A Use Case (or Interactor) encapsulates a single business logic operation, taking input parameters and returning output.
- Examples:
LoginUseCase,FetchUserDataUseCase. - Use Cases are part of Clean Architecture's Domain layer and are independent of UI frameworks.
- Create one when a piece of logic needs to be used from multiple ViewModels or tested independently.