@@ -13,28 +13,21 @@ const CONTEXT_TYPE = {
1313} ;
1414
1515export function connect < I , S > ( main : Plan < I , S > , opts = { history : false } ) : ( WrappedComponent : React . ComponentClass < any > ) => ConnectClass < I , S > {
16- return function ( WrappedComponent : React . ComponentClass < any > ) {
16+ return function ( WrappedComponent : ConnectClass < I , S > ) {
1717 let connectDisplayName = `Connect(${ getDisplayName ( WrappedComponent ) } )` ;
1818 if ( WrappedComponent . contextTypes === CONTEXT_TYPE ) {
19- return class ConnectNode extends Connect < I , S > {
19+ return class ConnectNode extends WrappedComponent {
2020 actions : Actions < I >
2121 update$ : Stream < Update < S > >
22+ main : Plan < I , S >
2223 static contextTypes = CONTEXT_TYPE
2324 static displayName = connectDisplayName
2425 constructor ( props , context ) {
2526 super ( props , context ) ;
2627 let { actions, update$ } = main ( context [ REACT_MOST_ENGINE ] . historyStream , props )
27- this . update$ = props . update$ ? update$ . merge ( props . update$ ) : update$
28- this . actions = Object . assign ( { } , bindActions ( actions , context [ REACT_MOST_ENGINE ] . intentStream , this ) , props . actions ) ;
29- }
30- render ( ) {
31- return h (
32- WrappedComponent ,
33- Object . assign ( { } , opts , this . props , {
34- update$ : this . update$ ,
35- actions : this . actions ,
36- } )
37- ) ;
28+ let { actions : preActions , update$ : preUpdates } = this . main ( context [ REACT_MOST_ENGINE ] . historyStream , props )
29+ this . update$ = preUpdates ? update$ . merge ( preUpdates ) : update$
30+ this . actions = Object . assign ( { } , bindActions ( actions , context [ REACT_MOST_ENGINE ] . intentStream , this ) , preActions ) ;
3831 }
3932 }
4033 } else {
@@ -43,6 +36,7 @@ export function connect<I, S>(main: Plan<I, S>, opts = { history: false }): (Wra
4336 update$ : Stream < Update < S > >
4437 traveler : Traveler < S >
4538 subscription : Subscription < S >
39+ main : Plan < I , S >
4640 static contextTypes = CONTEXT_TYPE
4741 static displayName = connectDisplayName
4842 constructor ( props , context ) {
@@ -54,7 +48,7 @@ export function connect<I, S>(main: Plan<I, S>, opts = { history: false }): (Wra
5448 return this . setState ( state ) ;
5549 } ) ;
5650 }
57-
51+ this . main = main
5852 let { actions, update$ } = main ( context [ REACT_MOST_ENGINE ] . intentStream , props )
5953 this . update$ = props . update$ ? props . update$ . merge ( update$ ) : update$
6054 this . actions = Object . assign ( { } , bindActions ( actions , context [ REACT_MOST_ENGINE ] . intentStream , this ) , props . actions ) ;
0 commit comments