refactor: tweak profile loader

This commit is contained in:
2024-06-25 16:14:53 +01:00
parent 1a405f7796
commit bdc94cec8b
5 changed files with 52 additions and 5 deletions

View File

@ -10,8 +10,9 @@ export interface KeyedHookFilter {
fn: HookFn;
}
export interface CacheEvents {
export interface CacheEvents<T> {
change: (keys: Array<string>) => void;
update: (v: T) => void;
}
export type CachedTable<T> = {
@ -41,12 +42,12 @@ export type CachedTable<T> = {
key(of: T): string;
snapshot(): Array<T>;
search(q: string): Promise<Array<T>>;
} & EventEmitter<CacheEvents>;
} & EventEmitter<CacheEvents<T>>;
/**
* Dexie backed generic hookable store
*/
export abstract class FeedCache<TCached> extends EventEmitter<CacheEvents> implements CachedTable<TCached> {
export abstract class FeedCache<TCached> extends EventEmitter<CacheEvents<TCached>> implements CachedTable<TCached> {
readonly name: string;
#snapshot: Array<TCached> = [];
protected log: ReturnType<typeof debug>;