member_webapp/@overflow/meta/service/meta-crawler.service.ts

28 lines
688 B
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import { Injectable } from '@angular/core';
2018-05-31 10:06:49 +00:00
import { Observable } from 'rxjs';
import { shareReplay, map } from 'rxjs/operators';
2018-05-24 06:44:13 +00:00
import { RPCService } from '@loafer/ng-rpc';
2018-05-02 08:09:39 +00:00
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
2018-04-06 11:02:18 +00:00
@Injectable()
export class MetaCrawlerService {
2018-05-31 10:06:49 +00:00
private metaCrawlerCache$: Observable<MetaCrawler[]>;
2018-04-06 11:02:18 +00:00
public constructor(
private rpcService: RPCService,
) {
}
public readAll(): Observable<MetaCrawler[]> {
2018-05-31 10:06:49 +00:00
if (!this.metaCrawlerCache$) {
this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe(
shareReplay<MetaCrawler[]>(1),
);
2018-05-31 11:53:11 +00:00
}
2018-05-31 10:06:49 +00:00
return this.metaCrawlerCache$;
2018-04-06 11:02:18 +00:00
}
}