storey 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 45

storey

Pub Travis CI CircleCI codecov

Redux like store but hierarchical.

Usage

A simple usage example:

import 'dart:async';

import 'package:storey/storey.dart';

class StringState {
  StringState(this.str);
  String str;
}

class OverwriteAction extends Action {
  const OverwriteAction(this.str);

  final String str;
}

StringState _handleOverwriteAction(StringState state, OverwriteAction action) {
  return state..str = action.str;
}

class ExchangeAction extends RequestAction<String> {
  ExchangeAction(this.str);
  final String str;
}

StringState _handleExchangeAction(StringState state, ExchangeAction action) {
  action.result = state.str;
  return state..str = action.str;
}

Reducer<StringState> _reducer = new MergedTypedReducer<StringState>(
    [
      new ProxyTypedReducer<StringState, OverwriteAction>(_handleOverwriteAction),
      new ProxyTypedReducer<StringState, ExchangeAction>(_handleExchangeAction),
    ]
);

Store<StringState> createStore(String initialStr) {
  return new Store<StringState>(
    name: 'app',
    initialState: new StringState(initialStr),
    reducer: _reducer,
    middlewares: <Middleware>[thunkMiddleware],
  );
}

Future<Null> main() async {
  Store<StringState> store = createStore('foo');
  assert(store.state.str == 'foo');

  store.dispatch(const OverwriteAction('bar'));
  assert(store.state.str == 'bar');

  ExchangeAction request = new ExchangeAction('foobar');
  store.dispatch(request);
  assert(store.state.str == 'foobar');
  assert(request.result == 'bar');
}

License

Released under The MIT License (MIT). See LICENSE for the full license text.

View Bindings

Clients

Recommendations

Changelog

0.2.2

  • Fix test coverage

0.2.1

  • Add factory constructor Action.empty() to construct empty action
  • Throw StateError if multiple reducers accept the dispatching action

0.2.0

  • Refactor thunk as a function that accepts a store and returns a value

0.1.0

  • Align store a name
  • Rename TypedMiddlewareBinding to ProxyTypedMiddleware
  • Fix skipped typed middleware due to null state
  • Add tests and CI support

0.0.1

  • Initial version

1. Depend on it

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


dependencies:
  storey: "^0.2.2"

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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:storey/storey.dart';
        
Version Uploaded Documentation Archive
0.2.2 Dec 10, 2017 Go to the documentation of storey 0.2.2 Download storey 0.2.2 archive
0.2.1 Dec 10, 2017 Go to the documentation of storey 0.2.1 Download storey 0.2.1 archive
0.2.0 Dec 10, 2017 Go to the documentation of storey 0.2.0 Download storey 0.2.0 archive
0.1.0 Dec 9, 2017 Go to the documentation of storey 0.1.0 Download storey 0.1.0 archive
0.0.1 Dec 7, 2017 Go to the documentation of storey 0.0.1 Download storey 0.0.1 archive

Analysis

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

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

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

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 3 hints.

    Strong-mode analysis of lib/src/store.dart failed with the following error:

    line: 234 col: 52
    The argument type '(Store<dynamic>) → String' can't be assigned to the parameter type '(dynamic) → dynamic'.

    Run dartfmt to format lib/src/thunk.dart.

    Similar analysis of the following files failed:

    • lib/storey.dart (hint)
  • The description is too short.

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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use storey.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
meta ^1.1.1 1.1.2
Dev dependencies
coverage ^0.9.3
test ^0.12.0