Files
agent-skills/skills/vueuse-functions/references/watchArray.md
Jason Woltje f5792c40be feat: Complete fleet — 94 skills across 10+ domains
Pulled ALL skills from 15 source repositories:
- anthropics/skills: 16 (docs, design, MCP, testing)
- obra/superpowers: 14 (TDD, debugging, agents, planning)
- coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth)
- better-auth/skills: 5 (auth patterns)
- vercel-labs/agent-skills: 5 (React, design, Vercel)
- antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo)
- Plus 13 individual skills from various repos

Mosaic Stack is not limited to coding — the Orchestrator and
subagents serve coding, business, design, marketing, writing,
logistics, analysis, and more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:27:42 -06:00

54 lines
1.1 KiB
Markdown

---
category: Watch
---
# watchArray
Watch for an array with additions and removals.
## Usage
Similar to `watch`, but provides the added and removed elements to the callback function. Pass `{ deep: true }` if the list is updated in place with `push`, `splice`, etc.
```ts
import { watchArray } from '@vueuse/core'
const list = ref([1, 2, 3])
watchArray(list, (newList, oldList, added, removed) => {
console.log(newList) // [1, 2, 3, 4]
console.log(oldList) // [1, 2, 3]
console.log(added) // [4]
console.log(removed) // []
})
onMounted(() => {
list.value = [...list.value, 4]
})
```
## Type Declarations
```ts
export declare type WatchArrayCallback<V = any, OV = any> = (
value: V,
oldValue: OV,
added: V,
removed: OV,
onCleanup: (cleanupFn: () => void) => void,
) => any
/**
* Watch for an array with additions and removals.
*
* @see https://vueuse.org/watchArray
*/
export declare function watchArray<
T,
Immediate extends Readonly<boolean> = false,
>(
source: WatchSource<T[]> | T[],
cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>,
options?: WatchOptions<Immediate>,
): WatchHandle
```