New singleton to hold cache globally in-memory

This commit is contained in:
Noel Maróti
2026-11-28 07:13:18 +01:00
parent 043a97ada5
commit 1988c0a61e
2 changed files with 33 additions and 0 deletions

16
src/app/cache.spec.ts Normal file
View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { Cache } from './cache';
describe('Cache', () => {
let service: Cache;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(Cache);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

17
src/app/cache.ts Normal file
View File

@@ -0,0 +1,17 @@
import { Injectable, signal } from '@angular/core';
import { Contact } from 'chatenium-sdk-preview';
@Injectable({
providedIn: 'root',
})
export class Cache {
contacts = signal<Contact[]>([])
contactsState = signal<LoadState>(LoadState.CLEAN_LOADING)
}
export enum LoadState {
CLEAN_LOADING,
CACHE_UPDATING,
LOADED,
ERROR
}