Skip to content

Commit

Permalink
feat: improve copyWith of ResourceReady and ResourceError
Browse files Browse the repository at this point in the history
  • Loading branch information
nank1ro committed Sep 6, 2023
1 parent 939fe30 commit f5c2bfc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
6 changes: 6 additions & 0 deletions packages/flutter_solidart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.1

### Changes from solidart

- **CHORE** Improve `copyWith` methods of `ResourceReady` and `ResourceError`

## 1.0.0

The core of the library has been rewritten in order to support automatic dependency tracking like SolidJS.
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_solidart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_solidart
description: A simple State Management solution for Flutter applications inspired by SolidJS
version: 1.0.0
version: 1.0.1
repository: https://github.com/nank1ro/solidart
documentation: https://docs.page/nank1ro/solidart~dev
topics:
Expand All @@ -16,7 +16,7 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.9.1
solidart: ^1.0.0
solidart: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
4 changes: 4 additions & 0 deletions packages/solidart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1

Improve `copyWith` methods of `ResourceReady` and `ResourceError`

## 1.0.0+4

Fix the pub.dev pub points.
Expand Down
15 changes: 9 additions & 6 deletions packages/solidart/lib/src/core/resource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,13 @@ class ResourceReady<T> implements ResourceState<T> {
@override
int get hashCode => Object.hash(runtimeType, value, isRefreshing);

/// Convenience method to update the [isRefreshing] value of a [Resource]
/// Convenience method to update the values of a [ResourceReady].
ResourceReady<T> copyWith({
T? value,
bool? isRefreshing,
}) {
return ResourceReady(
value,
return ResourceReady<T>(
value ?? this.value,
isRefreshing: isRefreshing ?? this.isRefreshing,
);
}
Expand Down Expand Up @@ -558,11 +559,13 @@ class ResourceError<T> implements ResourceState<T> {

/// Convenience method to update the [isRefreshing] value of a [Resource]
ResourceError<T> copyWith({
Object? error,
StackTrace? stackTrace,
bool? isRefreshing,
}) {
return ResourceError(
error,
stackTrace: stackTrace,
return ResourceError<T>(
error ?? this.error,
stackTrace: stackTrace ?? this.stackTrace,
isRefreshing: isRefreshing ?? this.isRefreshing,
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/solidart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: solidart
description: A simple State Management solution for Dart applications inspired by SolidJS
version: 1.0.0+4
version: 1.0.1
repository: https://github.com/nank1ro/solidart
documentation: https://docs.page/nank1ro/solidart~dev
topics:
Expand Down

0 comments on commit f5c2bfc

Please sign in to comment.