Skip to content

Commit

Permalink
Version bump: 23.0.0 = connectivity_plus: 6.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcglasberg committed May 1, 2024
1 parent afa136d commit fa1913e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ an <a href="https://github.com/marcglasberg/SameAppDifferentTech/blob/main/Mobil
Async Redux App Example Repository</a> in GitHub for a full-fledged example with a complete app
showcasing the fundamentals and best practices described in the AsyncRedux README.md file._

# 23.0.0

* Now using `connectivity_plus: 6.0.3` or up.

# 22.5.0

* You can now use `dispatchAll()` and `dispatchAndWaitAll()` to dispatch multiple actions
Expand Down
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1318,24 +1318,6 @@ dispatch(MyAction1(), notify: false);

<br>

## Alternatives to the Connector

The `StoreConnector` forces you to cleanly separate the widgets from the way they get their data.
This is better for clean code and will help a lot when you are writing tests.

However, if you want **and you know what you are doing**, here is how to access the store directly
from inside your widgets (for example in the `build` method):

```dart
/// Dispatch an action without a StoreConnector.
StoreProvider.dispatch<AppState>(context, MyAction());
/// Get the state, without a StoreConnector.
AppState state = StoreProvider.state<AppState>(context);
```

<br>

### Provider

Another good alternative to the `StoreConnector` is using
Expand Down Expand Up @@ -1935,7 +1917,7 @@ await store.waitCondition((state) => state.name == "Bill");
expect(store.state.name, "Bill");
```

#### Testing the StoreConnector's onInit and onInit
#### Testing the StoreConnector's onInit and onDispose

Suppose you want to start polling information when your user enters a particular screen, and stop
when the user leaves it. This could be your `StoreConnector`:
Expand Down
14 changes: 7 additions & 7 deletions lib/src/action_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import 'package:connectivity_plus/connectivity_plus.dart';
mixin CheckInternet<St> on ReduxAction<St> {
bool get ifOpenDialog => true;

UserException connectionException(ConnectivityResult result) =>
UserException connectionException(List<ConnectivityResult> result) =>
ConnectionException.noConnectivity;

/// If you are running tests, you can override this method to simulate the internet connection
Expand All @@ -65,9 +65,9 @@ mixin CheckInternet<St> on ReduxAction<St> {
/// Return `null` to use the real internet connection status.
static bool? Function() forceInternetOnOffSimulation = () => null;

Future<ConnectivityResult> checkConnectivity() async {
Future<List<ConnectivityResult>> checkConnectivity() async {
if (internetOnOffSimulation != null)
return internetOnOffSimulation! ? ConnectivityResult.wifi : ConnectivityResult.none;
return internetOnOffSimulation! ? [ConnectivityResult.wifi] : [ConnectivityResult.none];

return await (Connectivity().checkConnectivity());
}
Expand All @@ -76,7 +76,7 @@ mixin CheckInternet<St> on ReduxAction<St> {
Future<void> before() async {
var result = await checkConnectivity();

if (result == ConnectivityResult.none)
if (result.contains(ConnectivityResult.none))
throw connectionException(result).withDialog(ifOpenDialog);
}
}
Expand Down Expand Up @@ -141,17 +141,17 @@ mixin AbortWhenNoInternet<St> on ReduxAction<St> {
/// Return `null` to use the real internet connection status.
bool? get internetOnOffSimulation => CheckInternet.forceInternetOnOffSimulation();

Future<ConnectivityResult> checkConnectivity() async {
Future<List<ConnectivityResult>> checkConnectivity() async {
if (internetOnOffSimulation != null)
return internetOnOffSimulation! ? ConnectivityResult.wifi : ConnectivityResult.none;
return internetOnOffSimulation! ? [ConnectivityResult.wifi] : [ConnectivityResult.none];

return await (Connectivity().checkConnectivity());
}

@override
Future<void> before() async {
var result = await checkConnectivity();
if (result == ConnectivityResult.none) throw AbortDispatchException();
if (result.contains(ConnectivityResult.none)) throw AbortDispatchException();
}
}

Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: async_redux
description: Redux state management. An optimized Redux version, which is very easy to learn and use, yet powerful and tailored for Flutter. It allows both sync and async reducers.
version: 22.5.0
version: 23.0.0
# author: Marcelo Glasberg <[email protected]>
homepage: https://github.com/marcglasberg/async_redux
topics:
Expand All @@ -14,11 +14,11 @@ environment:
dependencies:
async_redux_core: ^1.2.0
meta: ^1.11.0
path_provider: ^2.1.1
path_provider: ^2.1.3
file: ^7.0.0
weak_map: ^3.0.0
fast_immutable_collections: ^10.1.2
connectivity_plus: ^5.0.2
fast_immutable_collections: ^10.2.2
connectivity_plus: ^6.0.3
collection: ^1.18.0
logging: ^1.2.0
path: ^1.8.3
Expand Down

0 comments on commit fa1913e

Please sign in to comment.