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';
|
2018-06-12 07:24:16 +00:00
|
|
|
import { shareReplay } from 'rxjs/operators';
|
2018-05-31 10:06:49 +00:00
|
|
|
|
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 13:37:11 +00:00
|
|
|
}
|
2018-05-31 10:06:49 +00:00
|
|
|
|
|
|
|
return this.metaCrawlerCache$;
|
2018-04-06 11:02:18 +00:00
|
|
|
}
|
|
|
|
}
|