Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJS updated, Property 'merge' does not exist on type 'typeof Observable'

I updated my material angular project to include an expandable detail row in my table. I needed to upgrade to rsjx 6 for this. Now I get the following error. I'm totally new with angular, so unfortunately I don't have a clue how to resolve this.

Property 'merge' does not exist on type 'typeof Observable'.

Can anyone help to resolve this error?

app.component.ts

  /** Connect function called by the table to retrieve one stream containing the data to render. */
  connect(): Observable<Track[]> {
    // Listen for any changes in the base data, sorting, filtering, or pagination
    const displayDataChanges = [
    this._exampleDatabase.dataChange,
    this._sort.sortChange,
    this._filterChange,
    this._paginator.page
    ];

    this._exampleDatabase.getAllTracks();

    return Observable.merge(...displayDataChanges).map(() => {
      // Filter data
      this.filteredData = this._exampleDatabase.data.slice().filter((track: Track) => {
        const searchStr = (track.id + track.title + track.artist + track.year + track.comment + track.path).toLowerCase();
        return searchStr.indexOf(this.filter.toLowerCase()) !== -1;
      });

      // Sort filtered data
      const sortedData = this.sortData(this.filteredData.slice());

      // Grab the page's slice of the filtered sorted data.
      const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
      this.renderedData = sortedData.splice(startIndex, this._paginator.pageSize);
      return this.renderedData;
    });
  }
like image 909
dgtl whiz Avatar asked Oct 14 '18 13:10

dgtl whiz


2 Answers

Static merge is imported as the following since version 6:

import {merge} from 'rxjs'

Then use it as:

merge(...)
like image 197
Lazar Ljubenović Avatar answered Nov 14 '22 21:11

Lazar Ljubenović


in old version of rxjs you use Observable.merge(...array).map(() => {});. for new versions i.e rxjs 6+ you have to use following syntax:

import { merge } from 'rxjs';
import { map } from 'rxjs/operators';

merge(...array).pipe(
  map(...),
  ...
);
like image 41
billyjov Avatar answered Nov 14 '22 22:11

billyjov