interface / @typed/async-data

NoData

Represents an asynchronous value before work or a result exists.

Package version
1.0.0-beta.7
Category
State models
Since
1.0.0

Import

import { NoData } from "@typed/async-data";

Signatures

export interface NoData {
    readonly _tag: "NoData";
}
export declare const NoData: NoData;

Why

A distinct initial state prevents absence from being confused with loading, failure, or a successful undefined value.

Ownership and lifetime

This shape acquires no resources. readonly is compile-time only; values matching the interface need not be frozen.

Property: _tag

The discriminant for the initial state.

Property: _tag: Why

A literal tag enables exhaustive matching without runtime class identity.

Property: _tag: Ownership and lifetime

Inherits the resource-free lifetime of its enclosing state.

Examples

import { NoData } from "@typed/async-data"
const initial = NoData

Source