Some Code Cleanup
This commit is contained in:
@@ -33,7 +33,7 @@ export function cached<T>(normal: T, init: () => Promise<T>): Cached<T> {
|
||||
init().then(data => {
|
||||
store.set(data);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
...readonly(store),
|
||||
@@ -52,7 +52,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
|
||||
const stores: Map<T, Cached<K>> = new Map();
|
||||
return (arg: T) => {
|
||||
if(stores.has(arg)) {
|
||||
return stores.get(arg)!!;
|
||||
return stores.get(arg)!;
|
||||
} else {
|
||||
const store = writable<K>(normal);
|
||||
let first = true;
|
||||
@@ -61,7 +61,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
|
||||
init(arg).then(data => {
|
||||
store.set(data);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const cachedStore = {
|
||||
...readonly(store),
|
||||
@@ -78,5 +78,5 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
|
||||
stores.set(arg, cachedStore);
|
||||
return cachedStore;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user