interface / @typed/async-data

Loading

Represents active work that has not produced a prior value or failure.

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

Import

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

Signatures

export interface Loading {
    readonly _tag: "Loading";
    readonly progress?: Progress | undefined;
}

Why

Loading is separate from refreshing so consumers can decide whether stale content remains available.

Ownership and lifetime

This plain object acquires no resources; the operation it describes is owned elsewhere and the object is not frozen.

Property: _tag

The discriminant for loading without a prior result.

Property: _tag: Why

The literal tag makes loading branches explicit and exhaustively checkable.

Property: _tag: Ownership and lifetime

Inherits the resource-free lifetime of its enclosing state.

Property: progress

Optional progress reported by the active producer.

Property: progress: Why

Keeping progress optional supports both determinate and uninstrumented operations.

Property: progress: Ownership and lifetime

Inherits the resource-free lifetime of its enclosing state.

Examples

import { loading } from "@typed/async-data"
const state = loading({ loaded: 0 })

Source