angular_redux 1.2.0 angular_redux: ^1.2.0 copied to clipboard
Bindings to use Redux state management with Angular Dart components
angular_redux.dart #
Bindings between Redux and Angular Dart.
Quick Start #
Add a Store<T>
factory:
Store<CounterState> createStore() => Store();
Add a NgStore<T>
factory:
NgStore<CounterState> createNgStore(Store<CounterState> store) => NgStore(store);
Make Store<T>
and NgStore<T>
injectable:
Module(
provides: [
FactoryProvider(Store, createStore),
FactoryProvider(NgStore, createNgStore),
],
)
Inject NgStore<T>
into a component:
final NgStore<CounterState> _store;
CounterApp(this._store);
Use select<S>
function to transform state into stream:
Stream<int> count;
void ngOnInit() {
count = _store.select((state) => state.count);
}
Use AsyncPipe
to render the stream in the template:
<div>
{{ count | async }}
</div>