title: Effect "AuthEffects.authLogin$" dispatched an invalid action: undefined
body: <p>In an Angular 6 (and RxJS) application I have an Effect that manages the Login. It first calls the server and then sets and decodes the token. At the end I added a last operation which handles the redirect.</p>
  
  <p>This is the case:
  User (not logged in) try to access in Profile page. In the AuthGuard I intercept it and I save the desired page (auth-guard.service.ts):</p>
  
  <pre><code> .. Here I already know that the user is not authenticated.
  let url = state.url;
    if (url) {
         .. I save in the Store the url
         this.store.dispatch(new CoreActions.SaveRedirectUrl(url));
   }
   this.router.navigate(['/login']);
   return false;
  </code></pre>
  
  <p>This is the last two part of the Auth Effect (<strong>auth.effects.ts</strong>, called when i dispatch the action <strong>DO_LOGIN</strong>):</p>
  
  <pre><code>, mergeMap((tokenObj: any) =&gt; {
      return [
          {
              type: AuthActions.LOGIN 
          },
          {
              type: AuthActions.SET_TOKEN,
              payload: tokenObj.token
          },
          {
              type: ProfileActions.DECODE_TOKEN,
              payload: tokenObj.token
          }
      ];
  })
  , exhaustMap(() =&gt; {
      return this.store.select('core')
          .pipe(
              map(coreState =&gt; {
                  if (coreState.redirectUrl) {
                      this.router.navigate([coreState.redirectUrl]);
                  } else {
                      this.router.navigate(['/']);
                  }
                  new CoreActions.RemoveRedirectUrl();
              }));
  }),
  </code></pre>
  
  <p>So I'm looking at this behaviour: after the the user has logged in, I save the token, I (eventually) redirect in the desired page, and then I remove that page from the State. I'm sure that the first mergeMap() works.. everything was broken when I added the last piece (exhaustMap), and I can not find a solution for the console error:</p>
  
  <blockquote>
    <p>ERROR Error: Effect "AuthEffects.authLogin$" dispatched an invalid action: undefined</p>
  </blockquote>
  
  <p>If I change the position of the last "return":</p>
  
  <pre><code>this.store.select('core') -----&gt; from here
      .pipe(
          map(coreState =&gt; {
              if (coreState.redirectUrl) {
                  this.router.navigate([coreState.redirectUrl]);
              } else {
                  this.router.navigate(['/']);
              }
              return new CoreActions.RemoveRedirectUrl(); -----&gt; to here
          }));
  </code></pre>
  
  <p>I have a compilation error on exhaustMap():</p>
  
  <blockquote>
    <p>Argument of type '() => void' is not assignable to parameter of type '(value: { type: string; payload?: undefined; } | { type: string; payload: any; }, index: number) ...'.
      Type 'void' is not assignable to type 'ObservableInput&lt;{}>'</p>
  </blockquote>