1

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)
3
  • I've never seen this typo (event.target as HTMLInputElement)... Why not simply map((value: Event) => value.target.value), ? Also, your keyUp is declared of type <string> which doesn't seem to be correct because you manage an Event, not a string. Also const observable = is not necessary until you subscribe to it later. Commented Jan 4, 2019 at 8:27
  • Okay but still the problem exist Commented Jan 4, 2019 at 9:14
  • Please, can you update the code ? Commented Jan 4, 2019 at 9:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.