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>
90 lines
1.7 KiB
Markdown
90 lines
1.7 KiB
Markdown
---
|
|
category: Sensors
|
|
---
|
|
|
|
# useIdle
|
|
|
|
Tracks whether the user is being inactive.
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
import { useIdle } from '@vueuse/core'
|
|
|
|
const { idle, lastActive } = useIdle(5 * 60 * 1000) // 5 min
|
|
|
|
console.log(idle.value) // true or false
|
|
```
|
|
|
|
Programatically resetting:
|
|
|
|
```ts
|
|
import { useCounter, useIdle } from '@vueuse/core'
|
|
import { watch } from 'vue'
|
|
|
|
const { inc, count } = useCounter()
|
|
|
|
const { idle, lastActive, reset } = useIdle(5 * 60 * 1000) // 5 min
|
|
|
|
watch(idle, (idleValue) => {
|
|
if (idleValue) {
|
|
inc()
|
|
console.log(`Triggered ${count.value} times`)
|
|
reset() // restarts the idle timer. Does not change lastActive value
|
|
}
|
|
})
|
|
```
|
|
|
|
## Component Usage
|
|
|
|
```vue
|
|
<template>
|
|
<UseIdle v-slot="{ idle }" :timeout="5 * 60 * 1000">
|
|
Is Idle: {{ idle }}
|
|
</UseIdle>
|
|
</template>
|
|
```
|
|
|
|
## Type Declarations
|
|
|
|
```ts
|
|
export interface UseIdleOptions
|
|
extends ConfigurableWindow,
|
|
ConfigurableEventFilter {
|
|
/**
|
|
* Event names that listen to for detected user activity
|
|
*
|
|
* @default ['mousemove', 'mousedown', 'resize', 'keydown', 'touchstart', 'wheel']
|
|
*/
|
|
events?: WindowEventName[]
|
|
/**
|
|
* Listen for document visibility change
|
|
*
|
|
* @default true
|
|
*/
|
|
listenForVisibilityChange?: boolean
|
|
/**
|
|
* Initial state of the ref idle
|
|
*
|
|
* @default false
|
|
*/
|
|
initialState?: boolean
|
|
}
|
|
export interface UseIdleReturn extends Stoppable {
|
|
idle: ShallowRef<boolean>
|
|
lastActive: ShallowRef<number>
|
|
reset: () => void
|
|
}
|
|
/**
|
|
* Tracks whether the user is being inactive.
|
|
*
|
|
* @see https://vueuse.org/useIdle
|
|
* @param timeout default to 1 minute
|
|
* @param options IdleOptions
|
|
*/
|
|
export declare function useIdle(
|
|
timeout?: number,
|
|
options?: UseIdleOptions,
|
|
): UseIdleReturn
|
|
```
|