Observable.of is not a function

后端 未结 19 734
旧时难觅i
旧时难觅i 2020-11-30 19:41

I am having issue with importing Observable.of function in my project. My Intellij sees everything. In my code I have:

import {Observable} from          


        
19条回答
  •  悲哀的现实
    2020-11-30 20:10

    Upgraded from Angular 5 / Rxjs 5 to Angular 6 / Rxjs 6?

    You must change your imports and your instantiation. Check out Damien's blog post

    Tl;dr:

    import { Observable, fromEvent, of } from 'rxjs';
    
    const yourResult = Observable
        .create(of(yourObservable))
        .startWith(null)
        .map(x => x.someStringProperty.toLowerCase());
    
    //subscribe to keyup event on input element
    Observable
        .create(fromEvent(yourInputElement, 'keyup'))
        .debounceTime(5000)
        .distinctUntilChanged()
        .subscribe((event) => {
            yourEventHandler(event);
        });
    

提交回复
热议问题