Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Wackerow <[email protected]>
  • Loading branch information
pettinarip and wackerow authored Oct 18, 2024
1 parent 2a76c93 commit 55432bf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/utils/data/dataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ export function dataLoader<T extends unknown[]>(
},
cacheTimeout?: number
): () => Promise<T> {
if (USE_MOCK_DATA) console.warn("Using mock data")
const cachedLoaders = loaders.map(([key, loader]) => {
const cachedLoader = cacheAsyncFn(key, loader, {
cacheTimeout,
})
return async () => {
try {
if (USE_MOCK_DATA) {
console.log("Using mock data for", key)
return await loadMockData(key)
}
if (USE_MOCK_DATA) return await loadMockData(key)

return await cachedLoader()
} catch (error) {
Expand Down

0 comments on commit 55432bf

Please sign in to comment.