mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-14 11:36:13 +01:00
18 lines
424 B
TypeScript
18 lines
424 B
TypeScript
import { getGroup } from '@/lib/api'
|
|
import { cache } from 'react'
|
|
|
|
function logAndCache<P extends any[], R>(fn: (...args: P) => R) {
|
|
const cached = cache((...args: P) => {
|
|
// console.log(`Not cached: ${fn.name}…`)
|
|
return fn(...args)
|
|
})
|
|
return (...args: P) => {
|
|
// console.log(`Calling cached ${fn.name}…`)
|
|
return cached(...args)
|
|
}
|
|
}
|
|
|
|
export const cached = {
|
|
getGroup: logAndCache(getGroup),
|
|
}
|