2
がrxjsに新しいですし、私はこれは私がrxjs機能にブール値を返すこと
私は変更するにはどうすればよい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>
}
}
を試してみましたが、何である
trueまたはfalseのいずれかの観察可能なを返したいの失敗します他のコンポーネントには、私が唯一の利用
return Observable.of(false)
代わりの
return false
this._authservice.checkLoggedin()
.subscribe.....//here get the value whether true or false
は、この瞬時に値を返すときに、あなたのHTTPService戻りデータを動作するはずです。 – Oisin
おかげで、それは –
@Oisin、実際には、彼はfalse'をsyncronously '返し詳しく見て動作しますセルゲイ。その後、あなたの代わりに '' observable'のsubscribtion'を返すため –