New singleton to hold cache globally in-memory
This commit is contained in:
16
src/app/cache.spec.ts
Normal file
16
src/app/cache.spec.ts
Normal 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
17
src/app/cache.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user