import { Injectable } from "@angular/core" ; @ Injectable ( ) export class PromiseCacheService { private keys : object = { } ; private maps : object = { } ; private static instance : PromiseCacheService = undefined ; static getInstance ( ) { return PromiseCacheService . instance ; } constructor ( ) { PromiseCacheService . instance = this ; } remove ( key ) { if ( key in this . map ) { delete this . keys [ this . map [ key ] ] ; } delete this . keys [ key ] ; } has ( key ) { return ( key in this . keys ) ; } get ( key ) { return this . keys [ key ] ; } set ( key , promise ) { return this . keys [ key ] = promise ; } map ( from , to ) { this . maps [ from ] = to ; } removeMap ( from ) { delete this . maps [ from ] ; } }