docs: add advanced skills for Vitest, Pinia, and Vue built-ins
Add comprehensive reference documentation for: - Vitest: environments, projects/workspaces, type testing, vi utilities - Pinia: HMR, Nuxt integration, SSR setup - Vue: built-in components (Transition, Teleport, Suspense, KeepAlive) and advanced directives
This commit is contained in:
52
.agents/skills/vueuse-functions/references/useCached.md
Normal file
52
.agents/skills/vueuse-functions/references/useCached.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
category: Utilities
|
||||
---
|
||||
|
||||
# useCached
|
||||
|
||||
Cache a ref with a custom comparator.
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { useCached } from '@vueuse/core'
|
||||
import { shallowRef } from 'vue'
|
||||
|
||||
interface Data {
|
||||
value: number
|
||||
extra: number
|
||||
}
|
||||
|
||||
const source = shallowRef<Data>({ value: 42, extra: 0 })
|
||||
const cached = useCached(source, (a, b) => a.value === b.value)
|
||||
|
||||
source.value = {
|
||||
value: 42,
|
||||
extra: 1,
|
||||
}
|
||||
|
||||
console.log(cached.value) // { value: 42, extra: 0 }
|
||||
|
||||
source.value = {
|
||||
value: 43,
|
||||
extra: 1,
|
||||
}
|
||||
|
||||
console.log(cached.value) // { value: 43, extra: 1 }
|
||||
```
|
||||
|
||||
## Type Declarations
|
||||
|
||||
```ts
|
||||
export interface UseCachedOptions<D extends boolean = true>
|
||||
extends ConfigurableDeepRefs<D>, WatchOptions {}
|
||||
export declare function useCached<T, D extends boolean = true>(
|
||||
refValue: Ref<T>,
|
||||
comparator?: (a: T, b: T) => boolean,
|
||||
options?: UseCachedOptions<D>,
|
||||
): UseCachedReturn<T, D>
|
||||
export type UseCachedReturn<
|
||||
T = any,
|
||||
D extends boolean = true,
|
||||
> = ShallowOrDeepRef<T, D>
|
||||
```
|
||||
Reference in New Issue
Block a user