26 lines
656 B
Dart
26 lines
656 B
Dart
// Base Repository Interface
|
|
//
|
|
// Gunakan interface ini sebagai template untuk membuat repository-nya.
|
|
// Repository pattern memisahkan logika pengambilan data dari service.
|
|
//
|
|
// Contoh:
|
|
// ```dart
|
|
// abstract class UserRepository {
|
|
// Future<User> getUserById(String userId);
|
|
// Future<List<User>> getAllUsers();
|
|
// Future<void> updateUser(User user);
|
|
// Future<void> deleteUser(String userId);
|
|
// }
|
|
// ```
|
|
|
|
abstract class BaseRepository {
|
|
// Template method untuk operasi yang dapat diulang
|
|
Future<T> execute<T>(Future<T> Function() operation) async {
|
|
try {
|
|
return await operation();
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|