@@ -22,7 +22,7 @@ describe('dispatchOnMount', () => {
22
22
} ;
23
23
let store = createStore ( reducer , applyMiddleware ( reduxObservable ( ) ) ) ;
24
24
25
- @dispatchOnMount ( ( ) => Observable . of ( { type : 'TEST' } ) )
25
+ @dispatchOnMount ( ( ) => ( ) => Observable . of ( { type : 'TEST' } ) )
26
26
class TestComponent extends Component {
27
27
}
28
28
@@ -56,7 +56,7 @@ describe('dispatchOnMount', () => {
56
56
} ;
57
57
} ) ;
58
58
59
- @dispatchOnMount ( ( ) => source1 , ( ) => source2 )
59
+ @dispatchOnMount ( ( ) => ( ) => source1 , ( ) => ( ) => source2 )
60
60
class TestComponent extends Component {
61
61
}
62
62
@@ -85,7 +85,7 @@ describe('dispatchOnMount', () => {
85
85
let source1 = Observable . of ( { type : 'SOURCE1' } ) ;
86
86
let source2 = Observable . of ( { type : 'SOURCE2' } ) ;
87
87
88
- @dispatchOnMount ( ( ) => source1 , ( ) => source2 )
88
+ @dispatchOnMount ( ( ) => ( ) => source1 , ( ) => ( ) => source2 )
89
89
class TestComponent extends Component {
90
90
}
91
91
@@ -111,7 +111,7 @@ describe('dispatchOnMount', () => {
111
111
112
112
let source2 = Observable . of ( { type : 'SOURCE2' } ) ;
113
113
114
- @dispatchOnMount ( { type : 'PLAIN_ACTION' } , ( ) => source2 )
114
+ @dispatchOnMount ( ( ) => ( { type : 'PLAIN_ACTION' } ) , ( ) => ( ) => source2 )
115
115
class TestComponent extends Component {
116
116
}
117
117
@@ -130,4 +130,34 @@ describe('dispatchOnMount', () => {
130
130
// let's just be really sure we don't break the unsub in the componentWillUnmount
131
131
expect ( ( ) => comp . componentWillUnmount ( ) ) . not . to . throw ( ) ;
132
132
} ) ;
133
+
134
+ it ( 'should accept factories that get invoked with props' , ( ) => {
135
+ let reducedActions = [ ] ;
136
+ let reducer = ( state , action ) => {
137
+ reducedActions . push ( action ) ;
138
+ return state ;
139
+ } ;
140
+ let store = createStore ( reducer , applyMiddleware ( reduxObservable ( ) ) ) ;
141
+
142
+ @dispatchOnMount (
143
+ ( props ) => ( { type : 'PLAIN_ACTION' , value : props . value } ) ,
144
+ ( props ) => ( ) => Observable . of ( { type : 'SOURCE2' , value : props . value } ) )
145
+ class TestComponent extends Component {
146
+ }
147
+
148
+ let comp = new TestComponent ( { value : 'Bilbo Bagginses' } ) ;
149
+ // fake connection?
150
+ comp . context = { store } ;
151
+ comp . componentDidMount ( ) ;
152
+
153
+ expect ( reducedActions ) . to . deep . equal ( [
154
+ { type : '@@redux/INIT' } ,
155
+ { type : 'PLAIN_ACTION' , value : 'Bilbo Bagginses' } ,
156
+ { type : 'SOURCE2' , value : 'Bilbo Bagginses' }
157
+ ] ) ;
158
+
159
+ // since plain actions don't return subscriptions, because they're not functions
160
+ // let's just be really sure we don't break the unsub in the componentWillUnmount
161
+ expect ( ( ) => comp . componentWillUnmount ( ) ) . not . to . throw ( ) ;
162
+ } ) ;
133
163
} ) ;
0 commit comments