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 %]
22
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()
77- [ ] unsubscribe when component unmount
8- - [ ] todo example
8+ - [X ] todo example
99- [ ] 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', () => {
250250 . then ( state => expect ( state . count ) . toEqual ( 6 ) )
251251 } )
252252 } )
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+ } )
253286} )
Original file line number Diff line number Diff line change 1- import { from , mergeArray } from 'most'
1+ import { from , of , mergeArray } from 'most'
22import { async as subject } from 'most-subject'
33export default function Engine ( ) {
44 const intentStream = subject ( ) ,
@@ -9,7 +9,12 @@ export default function Engine() {
99 travelStream . send = travelStream . next . bind ( travelStream ) ;
1010
1111 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 ) ;
1318 }
1419 historyStream . travel = travelStream ;
1520 return { intentStream, flatObserve, historyStream}
You can’t perform that action at this time.
0 commit comments