member_webapp/@overflow/meta/service/meta-crawler.service.ts
crusader 0a8dfe35fc ing
2018-05-31 22:37:11 +09:00

28 lines
690 B
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay, map } from 'rxjs/operators';
import { RPCService } from '@loafer/ng-rpc';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
@Injectable()
export class MetaCrawlerService {
private metaCrawlerCache$: Observable<MetaCrawler[]>;
public constructor(
private rpcService: RPCService,
) {
}
public readAll(): Observable<MetaCrawler[]> {
if (!this.metaCrawlerCache$) {
this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe(
shareReplay<MetaCrawler[]>(1),
);
}
return this.metaCrawlerCache$;
}
}