master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
Showing only changes of commit 84b17382c1 - Show all commits

View File

@ -1,5 +1,5 @@
<!-- <!--
* Copyright (C) 2022 WYATT GROUP * Copyright (C) 2023 WYATT GROUP
* Please see the AUTHORS file for details. * Please see the AUTHORS file for details.
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -19,11 +19,7 @@
# Flutter - Wyatt Architecture # Flutter - Wyatt Architecture
<p align="left"> <p align="left">
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"> <a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
<img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" />
</a>
<img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" /> <img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" />
</p> </p>
@ -31,10 +27,10 @@ The Wyatt Architecture for Flutter.
## Features ## Features
- Usecase * Usecase
- Repository * Repository
- DataSource * DataSource
- Entity * Entity
## Usage ## Usage
@ -79,7 +75,7 @@ And finaly create your different usecases :
Several use cases are supported : Several use cases are supported :
- Classic usecase : * Classic usecase :
```dart ```dart
class Test extends AsyncUseCase<QueryParameters, List<Photo>>> { class Test extends AsyncUseCase<QueryParameters, List<Photo>>> {
@ -109,7 +105,6 @@ class SearchPhotos extends AsyncUseCase<QueryParameters, List<Photo>>> {
return photos; return photos;
} }
@override @override
FutureOr<void> onStart(QueryParameters? params) { FutureOr<void> onStart(QueryParameters? params) {
if(params.start == null || params.limit == null){ if(params.start == null || params.limit == null){
@ -120,9 +115,9 @@ class SearchPhotos extends AsyncUseCase<QueryParameters, List<Photo>>> {
} }
``` ```
You can implement error scenarios overriding `onError`, or check postconditions by overriding `onComplete` . You can implement error scenarios overriding `onError` , or check postconditions by overriding `onComplete` .
- Stream usecase : * Stream usecase :
```dart ```dart
class SearchPhotos extends StreamUseCase<QueryParameters, List<Photo>>> { class SearchPhotos extends StreamUseCase<QueryParameters, List<Photo>>> {
@ -139,9 +134,9 @@ class SearchPhotos extends StreamUseCase<QueryParameters, List<Photo>>> {
} }
``` ```
On this case, observers allow you to add alternative scénarios when data changed, overriding `onData` or `onDone`. On this case, observers allow you to add alternative scenarios when data changed, overriding `onData` or `onDone` .
Please note that to use handlers, call `call` method and not `execute`. Please note that to use handlers, call `call` method and not `execute` .
> In fact, here we need a new parameter object, so let's create it: > In fact, here we need a new parameter object, so let's create it:
@ -156,7 +151,7 @@ class QueryParameters {
### Data ### Data
We start by creating models for photos and list of photos. You can use `freezed`. The `PhotoModel` extends `Photo` with some de/serializer capabilities. And those are used only in data layer. We start by creating models for photos and list of photos. You can use `freezed` . The `PhotoModel` extends `Photo` with some de/serializer capabilities. And those are used only in data layer.
Then implements your data sources: Then implements your data sources: