ageras-temporary-redux-segment
Version:
Segment.io analytics integration for redux.
48 lines (39 loc) • 995 B
text/typescript
import {Component, View, Inject, OnDestroy, OnInit} from 'angular2/core';
import {bindActionCreators} from 'redux';
import {Counter} from '../components/counter/counter';
import * as CounterActions from '../actions/counter';
({
selector: 'root'
})
({
directives: [Counter],
template: `
<counter [counter]="counter"
[increment]="increment"
[decrement]="decrement"
[incrementIfOdd]="incrementIfOdd"
[incrementAsync]="incrementAsync">
</counter>
`
})
export default class App implements OnDestroy, OnInit {
protected unsubscribe: Function;
constructor( ('ngRedux') private ngRedux) {
}
ngOnInit() {
this.unsubscribe = this.ngRedux.connect(
this.mapStateToThis,
this.mapDispatchToThis)(this);
}
ngOnDestroy() {
this.unsubscribe();
}
mapStateToThis(state) {
return {
counter: state.counter
};
}
mapDispatchToThis(dispatch) {
return bindActionCreators(CounterActions, dispatch);
}
}