storey 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 0

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

Use this package as a library

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

Alternatively, your editor might support pub 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
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0