Skip to content

Commit

Permalink
Merge pull request #21 from leancodepl/default-on-error-callback
Browse files Browse the repository at this point in the history
Add default onErrorCallback
  • Loading branch information
pdenert authored Mar 12, 2024
2 parents 9f87814 + 72a2f60 commit a691303
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.2

* Add default `onErrorCallback` for `RequestCubitBuilder`
* Change `PaginatedCubitLayout` first page error callback from `cubit.run` to `cubit.refresh`

## 0.0.1

* Initial version containing utilities for creating paginated page and page for performing a single request on a page.
2 changes: 1 addition & 1 deletion lib/src/paginated/paginated_cubit_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PaginatedCubitLayout<TData, TItem> extends StatelessWidget {
final callback = firstPageErrorBuilder ?? config.onFirstPageError;
return SliverFillRemaining(
hasScrollBody: false,
child: callback(context, error, cubit.run),
child: callback(context, error, cubit.refresh),
);
}

Expand Down
9 changes: 6 additions & 3 deletions lib/src/request/request_cubit_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ class RequestCubitBuilder<TOut, TError> extends StatelessWidget {
RequestRefreshState(:final data) => data != null
? builder(context, data)
: onLoading?.call(context) ?? config.onLoading(context),
RequestErrorState() =>
onError?.call(context, state, onErrorCallback) ??
config.onError(context, state, onErrorCallback),
RequestErrorState() => onError?.call(
context,
state,
onErrorCallback ?? cubit.refresh,
) ??
config.onError(context, state, onErrorCallback ?? cubit.refresh),
};
},
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: leancode_cubit_utils
description: A collection of cubits and widgets that facilitate the creation of repetitive pages, eliminating boilerplate.
version: 0.0.1
version: 0.0.2
repository: https://github.com/leancodepl/leancode_cubit_utils

environment:
Expand Down

0 comments on commit a691303

Please sign in to comment.