File

src/app/share/cache.service.ts

Index

Properties
Methods

Constructor

constructor()

Methods

get
get(key: string)
Type parameters :
  • T
Parameters :
Name Type Optional
key string No
Returns : T
set
set(key: string, value: any)
Parameters :
Name Type Optional
key string No
value any No
Returns : void
unset
unset(key)
Parameters :
Name Optional
key No
Returns : void

Properties

cache
Type : literal type
Default value : {}
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class CacheService {

  cache: { [key: string]: any } = {};

  constructor() { }

  get<T>(key: string): T {
    return this.cache[key];
  }

  set(key: string, value: any) {
    this.cache[key] = value;
  }

  unset(key) {
    this.cache[key] = null;
  }

}

result-matching ""

    No results matching ""