title: How to fix Cannot read property 'next' of undefined?
body: <p>In API service I want to add the error to notification.
  <code>processError</code> method is called in http request with binding : <code>catchError(error=&gt;this.processError(error)),</code></p>
  
  <p>api.service:</p>
  
  <pre><code>private processError(res: HttpErrorResponse) {
      this.currentErrorSubject.next(res);
      console.log('ERROR', res)
      // this.snackBar.open(`${res.message}`, 'Hide', {duration:10000, horizontalPosition: 'right', panelClass:['error-snack']})
      let notification = new Notification(1, 'error', 'HELLO KITTY')
      this.notificationService.addNotification(notification)
  
      return observableThrowError(res);
    }
  </code></pre>
  
  <p>notification.service:</p>
  
  <pre><code>@Injectable({
    providedIn: 'root'
  })
  export class NotificationService {
    isOpen : boolean
    private notifications = new Array&lt;Notification&gt;();
    public notificationsSubject: ReplaySubject&lt;Notification[]&gt;;
    constructor(
      private snackBar: MatSnackBar,
    ) { }
  
    open() {
      this.isOpen=true
  
    }
  
    addNotification(notification: Notification) {      
  
          this.notifications = [...this.notifications, notification];
          console.log('NOTIF', this.notifications)
  
          this.notificationsSubject.next(this.notifications);
      }
  </code></pre>
  
  <p>The error occurs in the '<code>addNotification</code>' function, where <code>this.notificationsSubject</code> is undefined. Can you explain why it is undefined? Thanks</p>