File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -248,19 +248,18 @@ describe('EffectSources', () => {
248248 it ( 'should resubscribe on error by default' , ( ) => {
249249 class Eff {
250250 @Effect ( )
251- b$ = hot ( 'a--b--c --d' ) . pipe (
251+ b$ = hot ( 'a--e-- b--e--c--e --d' ) . pipe (
252252 map ( v => {
253- if ( v == 'b ' ) throw new Error ( 'An Error' ) ;
253+ if ( v == 'e ' ) throw new Error ( 'An Error' ) ;
254254 return v ;
255255 } )
256256 ) ;
257257 }
258258
259259 const sources$ = of ( new Eff ( ) ) ;
260260
261- // 👇 'b' is ignored.
262- const expected = cold ( 'a-----c--d' ) ;
263-
261+ // 👇 'e' is ignored.
262+ const expected = cold ( 'a-----b-----c-----d' ) ;
264263 expect ( toActions ( sources$ ) ) . toBeObservable ( expected ) ;
265264 } ) ;
266265
@@ -516,17 +515,18 @@ describe('EffectSources', () => {
516515 const sources$ = of (
517516 new class {
518517 b$ = createEffect ( ( ) =>
519- hot ( 'a--b--c --d' ) . pipe (
518+ hot ( 'a--e-- b--e--c--e --d' ) . pipe (
520519 map ( v => {
521- if ( v == 'b ' ) throw new Error ( 'An Error' ) ;
520+ if ( v == 'e ' ) throw new Error ( 'An Error' ) ;
522521 return v ;
523522 } )
524523 )
525524 ) ;
526525 } ( )
527526 ) ;
528- // 👇 'b' is ignored.
529- const expected = cold ( 'a-----c--d' ) ;
527+
528+ // 👇 'e' is ignored.
529+ const expected = cold ( 'a-----b-----c-----d' ) ;
530530
531531 expect ( toActions ( sources$ ) ) . toBeObservable ( expected ) ;
532532 } ) ;
Original file line number Diff line number Diff line change @@ -25,13 +25,7 @@ export function mergeEffects(
2525 : sourceInstance [ propertyName ] ;
2626
2727 const resubscribable$ = resubscribeOnError
28- ? observable$ . pipe (
29- catchError ( error => {
30- if ( errorHandler ) errorHandler . handleError ( error ) ;
31- // Return observable that produces this particular effect
32- return observable$ ;
33- } )
34- )
28+ ? resubscribeInCaseOfError ( observable$ , errorHandler )
3529 : observable$ ;
3630
3731 if ( dispatch === false ) {
@@ -56,3 +50,16 @@ export function mergeEffects(
5650
5751 return merge ( ...observables$ ) ;
5852}
53+
54+ function resubscribeInCaseOfError < T extends Action > (
55+ observable$ : Observable < T > ,
56+ errorHandler ?: ErrorHandler
57+ ) : Observable < T > {
58+ return observable$ . pipe (
59+ catchError ( error => {
60+ if ( errorHandler ) errorHandler . handleError ( error ) ;
61+ // Return observable that produces this particular effect
62+ return resubscribeInCaseOfError ( observable$ , errorHandler ) ;
63+ } )
64+ ) ;
65+ }
You can’t perform that action at this time.
0 commit comments