user3577896
user3577896

Reputation: 25

rxjs - TypeError: Object(...) is not a function

I have application based on angular 6.10 and rxjs 6.3. I also have a problem :(

This is my code:

  public keyUp = new Subject<string>();
const observable = this.keyUp
      .pipe(
         map(value => (event.target as HTMLInputElement).value),
         debounceTime(300),
         distinctUntilChanged(),
         flatMap((search) => {
           return of(search).pipe(delay(300));
         }),
      )
      .subscribe((data) => {
        this.filter = data;
        this.onFilterChange(this.filter);
      });

This code is merged from rxjs 5.5.6 by me - unfortunately I dont remember the older version. This is error for actual version error:

ERROR TypeError: Object(...) is not a function
    at MergeMapSubscriber.eval [as project] (framework.js:232)
    at MergeMapSubscriber._tryNext (mergeMap.js:128)
    at MergeMapSubscriber._next (mergeMap.js:118)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:92)
    at DistinctUntilChangedSubscriber._next (distinctUntilChanged.js:104)
    at DistinctUntilChangedSubscriber.Subscriber.next (Subscriber.js:92)
    at DebounceTimeSubscriber.debouncedNext (debounceTime.js:101)
    at AsyncAction.dispatchNext (debounceTime.js:117)
    at AsyncAction._execute (AsyncAction.js:119)
    at AsyncAction.execute (AsyncAction.js:94)

Upvotes: 1

Views: 2868

Answers (1)

Maryam Saeidi
Maryam Saeidi

Reputation: 1533

For me, this error happened when my import was not correct.

My import was like:

import { tap } from 'rxjs/operators';

The correct version is:

import { tap } from 'rxjs/operators/tap';

Please check how you imported mergeMap operator.

Upvotes: 1

Related Questions