import cloneDeep from 'lodash.clonedeep' ; import { PoolDataService , SubgraphPoolBase } from './types' ; export class PoolCacher { private pools : SubgraphPoolBase [ ] = [ ] ; private _finishedFetching = false ; constructor ( private readonly poolDataService ) { } public get finishedFetching ( ) : boolean { return this . _finishedFetching ; } public getPools ( ) { return cloneDeep ( this . pools ) ; } public async fetchPools ( ) { try { this . pools = await this . poolDataService . getPools ( ) ; this . _finishedFetching = true ; return true ; } catch ( err ) { this . _finishedFetching = false ; this . pools = [ ] ; console . error ( `Error: fetchPools(): ${ err . message }` ) ; return false ; } } }