@@ -3,17 +3,21 @@ import { mergeMap } from 'rxjs/operator/mergeMap';
33import { exhaustMap } from 'rxjs/operator/exhaustMap' ;
44import { map } from 'rxjs/operator/map' ;
55import { dematerialize } from 'rxjs/operator/dematerialize' ;
6+ import { concat } from 'rxjs/observable/concat' ;
67import { Observable } from 'rxjs/Observable' ;
78import { Subject } from 'rxjs/Subject' ;
8- import { Injectable , isDevMode } from '@angular/core' ;
9+ import { Injectable } from '@angular/core' ;
910import { Action } from '@ngrx/store' ;
11+ import { EffectNotification , verifyOutput } from './effect_notification' ;
1012import { getSourceForInstance } from './effects_metadata' ;
11- import { resolveEffectSource , EffectNotification } from './effects_resolver' ;
13+ import { resolveEffectSource } from './effects_resolver' ;
1214import { ErrorReporter } from './error_reporter' ;
1315
1416@Injectable ( )
1517export class EffectSources extends Subject < any > {
16- constructor ( private errorReporter : ErrorReporter ) {
18+ constructor (
19+ private errorReporter : ErrorReporter ,
20+ ) {
1721 super ( ) ;
1822 }
1923
@@ -32,38 +36,7 @@ export class EffectSources extends Subject<any> {
3236 map . call (
3337 exhaustMap . call ( source$ , resolveEffectSource ) ,
3438 ( output : EffectNotification ) => {
35- switch ( output . notification . kind ) {
36- case 'N' : {
37- const action = output . notification . value ;
38- const isInvalidAction =
39- ! action || ! action . type || typeof action . type !== 'string' ;
40-
41- if ( isInvalidAction ) {
42- const errorReason = `Effect "${ output . sourceName } .${ output . propertyName } " dispatched an invalid action` ;
43-
44- this . errorReporter . report ( errorReason , {
45- Source : output . sourceInstance ,
46- Effect : output . effect ,
47- Dispatched : action ,
48- Notification : output . notification ,
49- } ) ;
50- }
51-
52- break ;
53- }
54- case 'E' : {
55- const errorReason = `Effect "${ output . sourceName } .${ output . propertyName } " threw an error` ;
56-
57- this . errorReporter . report ( errorReason , {
58- Source : output . sourceInstance ,
59- Effect : output . effect ,
60- Error : output . notification . error ,
61- Notification : output . notification ,
62- } ) ;
63-
64- break ;
65- }
66- }
39+ verifyOutput ( output , this . errorReporter ) ;
6740
6841 return output . notification ;
6942 } ,
0 commit comments