3
rxjsとangular2の新機能です。私はhttp呼び出しを中止してオブザーバブルを返すので、サブスクリプション終了時にエラーは出ません。私はちょうどここにオブジェクトを返す場合はもちろん、私たちは、私の知る限りは、あなたの状況を理解し、あなたが観察を返すようにしたいthis.abortSearches
がtrue
であるため、あなたがいずれかを実際にする必要はありませんが.searchAlbum(...).subscribe is not a function
rxjsですぐにサブスクリプションを中止して「解決」する方法はありますか?
public searchAlbum (term:string, queryObject?:any) {
if(this.abortSearches){
queryObject.body = null;
return //what to return here? used to be deferred.resolve(queryObject);
}
...
return this.http.request(new Request(options))
.map(res => this.extractData(res, queryObject))
.catch(this.handleError);
}
このコードのコンテキストは明確ではありません。おそらく、 'Observable.of(queryObject)'を返すべきです。リクエストの取り消しについては、こちらをご覧くださいhttp://stackoverflow.com/questions/36490926/how-to-cancel-a-httprequest-in-angular-2 – estus