I am trying to return a value inside a function that in turn return an observable but I am getting this error.
Property 'of' does not exist on type 'typeof Observable'.
can this be done without using Observable.of() method
import { Component, OnDestroy, OnInit } from '@angular/core';
import { interval, Subscription, Observable , of } from 'rxjs';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit,OnDestroy {
count:number = 10;
private firstObsSubscription : Subscription;
constructor() { }
ngOnInit() {
this.customObservable().subscribe((data:boolean)=>{
console.log(data);
})
}
customObservable():Observable<boolean>{
if (this.count === 10 ){
return Observable.of(true);
}
}
ngOnDestroy(){
this.firstObsSubscription.unsubscribe();
}
}