Am new to the rxjs and i would like to return an observable of either true or false
this is what i have tried
checkLoggedin():Observable<boolean> {
//check from server if user is loggdin
if(this._tokenService.getToken()){ //this returns synchronous true or false
this._httpservice.checkifloggedin()
.subscribe((res)=>{
return res.data //this comes in as true or false value
},
err=>{ return false }
)
}else{
return false //this fails with an error of
//type false is not assignable to observable<boolean>
}
}
How do i change the above else part to work with the boolean observable so that in the other components i can only do
this._authservice.checkLoggedin()
.subscribe.....//here get the value whether true or false