import { Injectable } from '@angular/core' ; import { Codelist } from "../shared/schema/codelist" ; import { paragraphNames } from "../shared/data/paragraph-names" ; import { itemNames } from "../shared/data/item-names" ; export class CodelistCache { [ k ] : Codelist [ ] ; } @ Injectable ( { providedIn : "root" } ) export class CodelistService { cache : CodelistCache = new CodelistCache ( ) ; constructor ( ) { this . cache [ "paragraph-names" ] = [ { _id : null , name : "paragraph-names" , validFrom : new Date ( 1990 , 0 , 1 ) , validTill : null , codelist : paragraphNames } ] ; this . cache [ "item-names" ] = [ { _id : null , name : "item-names" , validFrom : new Date ( 1990 , 0 , 1 ) , validTill : null , codelist : itemNames } ] ; } get ( name , date ) { return this . getCodelist ( name , date ) ; } getCodelist ( name , date ) { return new Promise ( ( resolve , reject ) => resolve ( this . getCached ( name , date ) ) ) ; } getCached ( name , date ) { return this . cache [ name ] [ 0 ] . codelist ; } saveCached ( name , codelist ) { return codelist . codelist ; } }