返回空的可观察量
2022-08-30 00:44:07
该函数应该从 get 请求返回more()
Observable
export class Collection {
public more = (): Observable<Response> => {
if (this.hasMore()) {
return this.fetch();
} else {
// return empty observable
}
};
private fetch = (): Observable<Response> => {
return this.http.get("some-url").map((res) => {
return res.json();
});
};
}
在这种情况下,如果为 true,我只能执行请求,否则我在函数上收到错误,如何返回空的 Observable?hasMore()
subscribe()
subscribe is not defined
this.collection.more().subscribe(
(res) => {
console.log(res);
}, (err) => {
console.log(err);
}
);