redux_future_middleware 0.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • new48

Redux Future Middleware (Dart/Flutter) #

Pub Build Status codecov

Redux middleware package for handling Dart Futures by creating a FutureAction.

The futureMiddleware can be attached to the Redux store upon construction.

Once attached, you can store.dipatch the FutureAction, and the futureMiddleware will intercept it.

  • If the Future passed in FutureAction completes successfully, a FutureSuccessAction will be dipatched with the result of the Future.
  • If the Future passed in FutureAction fails, a FutureErrorAction will be dispatched containing the error that was returned.
  • When the FutureAction is dipatches, a FuturePendingAction is dispatched from the futureMiddleware for consumption by the Reducer.

Usage: #

main() {
    // First, create an action to uniquely identify each FutureAction from others.
    class ExampleAction {}

    // Then, create a reducer that knows how to handle the future actions
    String exampleReducer(String state, dynamic action) {
        if (action is FuturePendingAction<ExampleAction>) {
            return 'Fetching';
        } else if (action is FutureSuccessAction<ExampleAction, String>) {
            return action.payload;
        } else if (action is FutureErrorAction<ExampleAction>) {
            return action.error.toString();
        }

        return state;
    }

    // Next, create a store that includes `futureMiddleware`. It will
    // intercept all `FutureAction` that are dispatched.
    final store = Store(
        exampleReducer,
        middleware: [futureMiddleware],
    );

    // Next, dispatch `FutureAction` for intercepting.
    store.dipatch(FutureAction<ExampleAction, String>(
        future: Future.value('Hi')));
}

Credits: #

v0.1.0+1 #

Initial Release

example/README.md

Redux Future Middleware Example #

This example is the counter starter project implemented using Redux and futureMiddleware to showcase the usage of redux-future-middleware.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  redux_future_middleware: ^0.1.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:redux_future_middleware/redux_future_middleware.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Dec 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:redux_future_middleware/redux_future_middleware.dart.

Health issues and suggestions

Document public APIs. (-1 points)

27 out of 27 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (redux).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
meta ^1.1.6 1.1.8
redux ^3.0.0 3.0.0 4.0.0
Dev dependencies
test ^1.9.4
test_coverage ^0.4.0