# AsyncOnceCell

`import { AsyncOnceCell } from "destack:async";`

One-time async initialized cell.

```ds title="AsyncOnceCell"
export class AsyncOnceCell<T> {
    value: MaybeUninit<T>;
    get(): &readonly T | undefined;
    set(value: ^T): Result<void, ^T>;
    getOrInit(init: () => Task<T>): Task<&readonly T>;
    take(): T | undefined;
}
```

[language/library/src/async/once.ds:21:44](https://github.com/destack-sh/destack/blob/main/language/library/src/async/once.ds#L21-L44)

## Members

### `value: MaybeUninit<T>`

The stored value.

### `get(): &readonly T | undefined`

Get the initialized value.

### `set(value: ^T): Result<void, ^T>`

Set the value once.

### `getOrInit(init: () => Task<T>): Task<&readonly T>`

Get the value or initialize it.

### `take(): T | undefined`

Move the value out when initialized.
