member_webapp/@overflow/meta/service/meta-crawler.service.ts
2018-05-31 20:53:11 +09:00

28 lines
688 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$;
}
}