Created
August 15, 2021 20:41
-
-
Save yarn-rp/a09094bb14e72e2aac5ff84eb76c120c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class UseCase<Type, Params> { | |
Future<Either<Failure, Type>> call(Params params); | |
} | |
class GetProfile extends UseCase<MyProfile, NoParams> { | |
final ProfileRepository repository; | |
GetProfile({required this.repository}); | |
@override | |
Future<Either<Failure, MyProfile>> call(NoParams params) => | |
repository.getProfile(); | |
} | |
class EditProfile extends UseCase<MyProfile, EditProfileParams> { | |
final ProfileRepository repository; | |
EditProfile({required this.repository}); | |
@override | |
Future<Either<Failure, MyProfile>> call(EditProfileParams params) => | |
repository.editProfile(params); | |
} | |
class DeleteProfile extends UseCase<Unit, NoParams> { | |
final ProfileRepository repository; | |
GetProfile({required this.repository}); | |
@override | |
Future<Either<Failure, Unit>> call(NoParams params) => | |
repository.deleteProfile(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment