File tree Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Original file line number Diff line number Diff line change 1
- * RoadMap [0 %]
1
+ * RoadMap [50 %]
2
2
3
- - [ ] modular, extra engine.
4
- - [ ] time travel
5
- - [ ] inspect
6
- - [ ] history.back()
3
+ - [X ] modular, extra engine.
4
+ - [X ] time travel
5
+ - [X ] inspect
6
+ - [X ] history.back()
7
7
- [ ] unsubscribe when component unmount
8
- - [ ] todo example
8
+ - [X ] todo example
9
9
- [ ] router example
10
- - [ ]
10
+ - [ ] typescript typedef
11
+ - [ ] flow type
Original file line number Diff line number Diff line change @@ -250,4 +250,37 @@ describe('react-most', () => {
250
250
. then ( state => expect ( state . count ) . toEqual ( 6 ) )
251
251
} )
252
252
} )
253
+
254
+ describe ( 'convension default to `action` field in sinks' , ( ) => {
255
+ const Counter = connect ( intent$ => {
256
+ return {
257
+ sink$ : intent$ . map ( intent => {
258
+ switch ( intent . type ) {
259
+ case 'exception' :
260
+ throw new Error ( 'exception in reducer' )
261
+ default :
262
+ return state => state
263
+ }
264
+ } ) ,
265
+ actions : {
266
+ throwExeption : ( ) => ( { type : 'exception' } )
267
+ } ,
268
+ }
269
+ } ) ( CounterView )
270
+
271
+ it ( 'should recover to identity stream and log exception' , ( ) => {
272
+ spyOn ( console , 'error' )
273
+ let counterWrapper = TestUtils . renderIntoDocument (
274
+ < Most >
275
+ < Counter history = { true } />
276
+ </ Most >
277
+ )
278
+ let counter = TestUtils . findRenderedComponentWithType ( counterWrapper , Counter )
279
+ return do$ ( [
280
+ counter . actions . throwExeption ,
281
+ ] ) . then ( ( ) => {
282
+ expect ( console . error ) . toHaveBeenCalled ( )
283
+ } )
284
+ } )
285
+ } )
253
286
} )
Original file line number Diff line number Diff line change 1
- import { from , mergeArray } from 'most'
1
+ import { from , of , mergeArray } from 'most'
2
2
import { async as subject } from 'most-subject'
3
3
export default function Engine ( ) {
4
4
const intentStream = subject ( ) ,
@@ -9,7 +9,12 @@ export default function Engine() {
9
9
travelStream . send = travelStream . next . bind ( travelStream ) ;
10
10
11
11
function flatObserve ( actionsSinks , f ) {
12
- return mergeArray ( actionsSinks ) . observe ( f ) ;
12
+ return mergeArray ( actionsSinks )
13
+ . recoverWith ( e => {
14
+ console . error ( 'There is Error in your reducer:' , e , e . stack )
15
+ return of ( x => x )
16
+ } )
17
+ . observe ( f ) ;
13
18
}
14
19
historyStream . travel = travelStream ;
15
20
return { intentStream, flatObserve, historyStream}
You can’t perform that action at this time.
0 commit comments