simple_redux 0.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

Simple redux implementation in Dart. Inspired by https://jayrambhia.com/blog/android-redux-intro

Created from templates made available by Stagehand under a BSD-style license.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.0.0 #

  • Initial version, created by Stagehand

example/simple_redux_example.dart

import 'package:simple_redux/simple_redux.dart';

void main() {
  final reducers = <Reducer<double>>[
    (state, action) {
      if (action is Add) {
        return state + action.argument;
      }

      return state;
    },
    (state, action) {
      if (action is Subtract) {
        return state - action.argument;
      }

      return state;
    },
    (state, action) {
      if (action is Multiply) {
        return state * action.argument;
      }

      return state;
    },
    (state, action) {
      if (action is Negation) {
        return -state;
      }

      return state;
    },
  ];
  final store = SimpleStore<double>(0, reducers: reducers);

  Dispatch disp;
  final unsub = store.subscribe((state, dispatch) {
    print("State is: $state");
    disp = dispatch;
  });

  disp(Add(15));
  disp(Subtract(12));
  disp(Multiply(40));
  disp(Negation());
}

class Add extends Action {
  final double argument;

  Add(this.argument);
}

class Subtract extends Action {
  final double argument;

  Subtract(this.argument);
}

class Multiply extends Action {
  final double argument;

  Multiply(this.argument);
}

class Negation extends Action {}

Use this package as a library

1. Depend on it

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


dependencies:
  simple_redux: ^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:simple_redux/simple_redux.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]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Health issues and suggestions

Document public APIs. (-1 points)

15 out of 15 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0