import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional/Functions/computedAsync - Async computed property'/>

# `computedAsync`

Creates a computed property that can handle asynchronous getters. Unlike Vue's standard `computed`, `computedAsync` accepts async functions, synchronous functions, or raw values — the result is automatically resolved and exposed as a reactive computed ref. Initialization is lazy and occurs upon first access to the property.

**Parameters:**
- `getter: (() => Promise<R>) | (() => R) | R` — An async function, synchronous function, or raw value to compute the result from.
- `initialState?: R` — The initial value of the result.
- `ignore?: R` — A value to be ignored (will not be set as the result).
- `debugOptions?: DebuggerOptions` — Options used for debugging reactive computations, supported by Vue.js.

**Returns:**
`ComputedRef<R | undefined>` — A reactive computed ref containing the resolved result of the getter.

```typescript
import { computedAsync } from '@dxtmisha/functional'

// Initial state
const status = computedAsync(async () => {
  await new Promise(resolve => setTimeout(resolve, 1000))
  return 'online'
}, 'offline')
// status.value is 'offline' immediately, and 'online' after 1 second

// Async getter
const data = computedAsync(async () => {
  const response = await fetch('/api/data')
  return response.json()
})

// Sync getter
const label = computedAsync(() => 'Hello, World!')

// Raw value
const count = computedAsync(42)
```
