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

28 lines
690 B
TypeScript
Raw Normal View History

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