title: Refactoring rxjs 5 to rxjs 6 code - retryWhen
body: <p>I've had this service code written in rxjs 5 notation:</p>
  
  <pre><code>      constructor(private _authService: AuthService) {
      this._ws$ = WebSocketSubject.create&lt;any&gt;({
        url: WS_URL,
        protocol: this._authService.token
      });
  
      this._ws$.retryWhen(errors =&gt; {
          // switchMap to retrieve the source error
          return errors.switchMap(sourceErr =&gt; {
              console.log('Retry WS.', sourceErr);
              return Observable.timer(1000).map(() =&gt; Observable.of(true));
            }
          );
        }
      ).subscribe(
        msg =&gt; {
          if ('channel_name' in msg) {
            console.log('Channel name', msg.channel_name);
            this._channelName = msg.channel_name;
            this._authService.channelName = msg.channel_name;
          }
          this.subject$.next(msg);
          console.log(msg);
        },
        err =&gt; {
          console.log(err);
          this.subject$.error(err);
        },
        () =&gt; this.subject$.complete()
      );
    }
  </code></pre>
  
  <p>I am trying to refactor it to rxjs 6 valid code and I have got this now:</p>
  
  <pre><code>constructor(private _authService: AuthService) {
  this._ws$ = WebSocketSubject.create({
    url: WS_URL,
    protocol: this._authService.token
  });
  
  retryWhen(() =&gt; {
      // switchMap to retrieve the source error
      return switchMap(() =&gt; {
          return timer(1000).pipe(map(() =&gt; of(true)));
        }
      );
    }
  ).subscribe(
    msg =&gt; {
      if ('channel_name' in msg) {
        this._channelName = msg.channel_name;
        this._authService.channelName = msg.channel_name;
      }
      this.subject$.next(msg);
    },
    err =&gt; {
      this.subject$.error(err);
    },
    () =&gt; this.subject$.complete()
  );
  </code></pre>
  
  <p>But I am getting following error:</p>
  
  <pre><code>TS2345: Argument of type '() =&gt; OperatorFunction&lt;{}, Observable&lt;boolean&gt;&gt;' is not assignable to parameter of type '(errors: Observable&lt;any&gt;) =&gt; Observable&lt;any&gt;'.
      Type 'OperatorFunction&lt;{}, Observable&lt;boolean&gt;&gt;' is not assignable to type 'Observable&lt;any&gt;'.
      Property '_isScalar' is missing in type 'OperatorFunction&lt;{}, Observable&lt;boolean&gt;&gt;'.
  </code></pre>
  
  <p>I cannot figure out what is the best way of using retryWhen function here and how to use WebSocketSubject inside it.</p>