incredux 0.1.2 copy "incredux: ^0.1.2" to clipboard
incredux: ^0.1.2 copied to clipboard

A starting point for Dart libraries or applications.

incredux #

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

Usage #

A simple usage example:

import 'package:redux/redux.dart';
import 'package:incredux/incredux.dart';

enum Actions { increment, decrement }

void main() {
  when(Actions.increment, (store) => print('(Increment) state: ${store.state}'));

  when( Actions.decrement, (store) => print('(Decrement) state: ${store.state}'));

  int counterReducer(int state, dynamic action) {
    if (action == Actions.increment) {
      return state + 1;
    } else if (action == Actions.decrement) {
      return state - 1;
    }

    return state;
  }

  var store = Store<int>(
    counterReducer,
    initialState: 0,
    middleware: <Middleware<int>>[
      incredux<int>()
    ],
  );

  store.dispatch(Actions.increment); // Print: `(Increment) state: 1`
  store.dispatch(Actions.decrement); // Print: `(Increment) state: 0` - because did call increment before
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A starting point for Dart libraries or applications.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

redux

More

Packages that depend on incredux