-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- core usecase module - get-settings refactoring & test upgrade
- Loading branch information
1 parent
579ce63
commit 7214b04
Showing
4 changed files
with
68 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"marganam", | ||
"mockito", | ||
"mrjc", | ||
"mrjf" | ||
"mrjf", | ||
"usecase" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:dartz/dartz.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:sprightly/core/formatted_exception.dart'; | ||
|
||
abstract class UseCase<T, Params> { | ||
Future<Either<FormattedException, T>> call(Params params); | ||
} | ||
|
||
// This will be used by the [UseCase] which | ||
// doesn't accept any parameters. | ||
class NoParams extends Equatable { | ||
@override | ||
List<Object> get props => []; | ||
} |
21 changes: 15 additions & 6 deletions
21
src/sprightly/lib/features/settings/domain/usecases/get-settings.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
import 'package:dartz/dartz.dart'; | ||
import 'package:sprightly/core/dartz_execution.dart'; | ||
import 'package:sprightly/core/formatted_exception.dart'; | ||
import 'package:sprightly/core/usecase.dart'; | ||
import 'package:sprightly/features/settings/domain/entities/setting-entities.dart'; | ||
import 'package:sprightly/features/settings/domain/repositories/setting-repositories.dart'; | ||
|
||
class GetSettings { | ||
class GetAppDetails extends UseCase<AppDetails, NoParams> { | ||
final SettingsRepo _repo; | ||
|
||
GetSettings(this._repo); | ||
GetAppDetails(this._repo); | ||
|
||
Future<Either<FormattedException, AppDetails>> getAppDetails() => | ||
@override | ||
Future<Either<FormattedException, AppDetails>> call(NoParams noParams) => | ||
DartzExecution.call<AppDetails>(() => _repo.appDetails, | ||
moduleName: 'GetSettings.getAppDetails'); | ||
Future<Either<FormattedException, AppSettings>> getAppSettings() => | ||
moduleName: 'GetAppDetails'); | ||
} | ||
|
||
class GetAppSettings extends UseCase<AppSettings, NoParams> { | ||
final SettingsRepo _repo; | ||
GetAppSettings(this._repo); | ||
|
||
@override | ||
Future<Either<FormattedException, AppSettings>> call(NoParams noParams) => | ||
DartzExecution.call<AppSettings>(() => _repo.appSettings, | ||
moduleName: 'GetSettings.getAppSettings'); | ||
moduleName: 'GetAppSettings'); | ||
} |
This file contains 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