1- import { Component , View , onInit , onDestroy } from 'angular2/angular2' ;
1+ import { Component , View , onDestroy } from 'angular2/angular2' ;
22import { bindActionCreators } from 'redux' ;
33import { Counter } from '../components/Counter' ;
44import * as CounterActions from '../actions/CounterActions' ;
55import { Inject } from 'angular2/di' ;
66
77@Component ( {
88 selector : 'root' ,
9- lifecycle : [ onInit , onDestroy ] ,
10- bindings : [ ]
9+ lifecycle : [ onDestroy ]
1110} )
1211@View ( {
1312 directives : [ Counter ] ,
1413 template : `
1514 <counter [counter]="counter"
1615 [increment]="increment"
1716 [decrement]="decrement"
18- [increment-If-Odd ]="incrementIfOdd"
19- [increment-Async ]="incrementAsync">
17+ [increment-if-odd ]="incrementIfOdd"
18+ [increment-async ]="incrementAsync">
2019 </counter>
21- <dev
2220 `
2321} )
2422export default class App {
@@ -27,22 +25,20 @@ export default class App {
2725
2826 constructor ( @Inject ( 'ngRedux' ) ngRedux , @Inject ( 'devTools' ) devTools ) {
2927 devTools . start ( ngRedux ) ;
30- this . unsubscribe = ngRedux . connect ( this . mapState , this . mapDispatch ) ( this ) ;
28+ this . unsubscribe = ngRedux . connect ( this . mapStateToThis , this . mapDispatchToThis ) ( this ) ;
3129 }
3230
33- onInit ( ) { }
34-
3531 onDestroy ( ) {
3632 this . unsubscribe ( ) ;
3733 }
3834
39- mapState ( state ) {
35+ mapStateToThis ( state ) {
4036 return {
4137 counter : state . counter
4238 } ;
4339 }
4440
45- mapDispatch ( dispatch ) {
41+ mapDispatchToThis ( dispatch ) {
4642 return bindActionCreators ( CounterActions , dispatch ) ;
4743 }
4844}
0 commit comments