meta_types_redux 0.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 39

meta_types_redux

An extension of redux.dart that uses meta types to enforce type safety and implement slick reducer/middlware declarations.

0.0.1

  • initial annotations for annotating union, enum, and data classes

example/example.dart

import 'package:meta_types/meta_types.dart';
import 'package:meta_types_redux/meta_types_redux.dart';

part 'example.g.dart';

@DataClass()
abstract class $Counter {
  int get count => 0;
}

// $Counter tells the generator the state to use for the
// reducer and middlwarehandler code should be of type Counter
@Actions($Counter)
@SealedClass()
abstract class $CounterActions {
  int get increment;
  int get decrement;
}

void main() {
  final store = MetaTypesStore<Counter, CounterActions>(
    reducer: myReducer,
    initialState: Counter(),
    metaMiddleware: [myMiddleware],
    syncStream: true,
  );

  store.onChange.listen((state) => print(state.count));

  store.dispatch(CounterActions.incrementFactory(1));
  // increment mw: 1
  // 1
  store.dispatch(CounterActions.incrementFactory(4));
  // increment mw: 4
  // 5
  store.dispatch(CounterActions.decrementFactory(1));
  // decrement mw: 1
  // 4
}

final myReducer = (Counter c, CounterActions a) => a.reduce(
      c,
      increment: _increment,
      decrement: _decrement,
    );

Counter _increment(Counter state, int val) =>
    state.clone(count: state.count + val);

Counter _decrement(Counter state, int val) =>
    state.clone(count: state.count - val);

final myMiddleware = (
  MiddlewareApi<Counter, CounterActions> api,
  MetaNextDispatcher next,
  CounterActions a,
) =>
    a.handleMiddleware(
      api,
      next,
      increment: _incrementHandler,
      decrement: _decrementHandler,
    );

void _incrementHandler(MiddlewareApi<Counter, CounterActions> api,
    MetaNextDispatcher next, int val) {
  print('increment mw: $val');
  next();
}

void _decrementHandler(MiddlewareApi<Counter, CounterActions> api,
    MetaNextDispatcher next, int val) {
  print('decrement mw: $val');
  next();
}

Use this package as a library

1. Depend on it

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


dependencies:
  meta_types_redux: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:meta_types_redux/meta_types_redux.dart';
  
Version Uploaded Documentation Archive
0.1.0 Aug 7, 2018 Go to the documentation of meta_types_redux 0.1.0 Download meta_types_redux 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
91
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
39
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

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

Health issues and suggestions

Document public APIs (-9.23 points)

12 out of 13 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Maintenance issues and suggestions

Homepage does not exists. (-20 points)

We were unable to access https://github.com/davidmarne/dart_meta_types/meta_types_redux at the time of the analysis.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2-0-0-dev <3.0.0
meta ^1.0.0 1.1.6
meta_types ^0.1.0 0.1.0
redux ^3.0.0 3.0.0
Dev dependencies
build_runner ^0.9.0
meta_types_generator ^0.1.0
meta_types_redux_generator