Skip to content

Commit 386ba8f

Browse files
committed
Update ReadMe
1 parent 3eb39d9 commit 386ba8f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

packages/leancode_cubit_utils/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ Implementation of cubits for handling [CQRS](https://pub.dev/packages/cqrs) quer
2121

2222
### `RequestCubit`
2323

24-
`RequestCubit` is used to execute a single API request. It has four generic arguments:
24+
`RequestCubit` is used to execute a single API request. It has three generic arguments:
2525
- `TRes` specifies what the request returns,
26-
- `TData` specifies what is kept in TRes as response body,
2726
- `TOut` determines which model we want to emit as data in the state,
28-
- `TError` defines error's type. In the example below.
27+
- `TError` defines error's type.
2928

3029
`HttpRequestCubit` in the example below provides the generic http implementation that can be used while defining all needed `RequestCubits`.
3130

3231
```dart
3332
/// Base class for http request cubits.
3433
abstract class HttpRequestCubit<TOut>
35-
extends RequestCubit<http.Response, String, TOut, int> {
34+
extends RequestCubit<http.Response, TOut, int> {
3635
HttpRequestCubit(super.loggerTag, {required this.client});
3736
3837
final http.Client client;
3938
39+
/// Maps the given [data] to the output type [TOut].
40+
TOut map(String data);
41+
4042
@override
4143
/// Client-specific method needed for handling the API response.
4244
Future<RequestState<TOut, int>> handleResult(
@@ -72,7 +74,7 @@ class ProjectDetailsCubit extends HttpRequestCubit<ProjectDetailsDTO> {
7274
final String id;
7375
7476
@override
75-
// This method allows to map the given TRes into TOut.
77+
// This method allows to map the given data into TOut.
7678
ProjectDetailsDTO map(String data) =>
7779
ProjectDetailsDTO.fromJson(jsonDecode(data) as Map<String, dynamic>);
7880
@@ -90,7 +92,7 @@ The cubit itself handles the things like:
9092
- logging - you can observe what is happening inside of the cubit.
9193

9294
### `ArgsRequestCubit`
93-
`ArgsRequestCubit<TArgs, TRes, TData, TOut, TError>` is a version of `RequestCubit` in which the request method accepts an argument. `TArgs` determines the type of arguments accepted by the request method. `TRes`, `TData`, `TOut` and `TError` serve the same purpose as in `RequestCubit`.
95+
`ArgsRequestCubit<TArgs, TRes, TOut, TError>` is a version of `RequestCubit` in which the request method accepts an argument. `TArgs` determines the type of arguments accepted by the request method. `TRes`, `TOut` and `TError` serve the same purpose as in `RequestCubit`.
9496

9597
If you call `refresh()` on `ArgsRequestCubit` it will perform a request with the last used arguments. They are also available under `lastRequestArgs` field.
9698

0 commit comments

Comments
 (0)