member_webapp/@overflow/meta/service/meta-crawler.service.ts
2018-06-12 16:24:16 +09:00

28 lines
685 B
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay } 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$;
}
}