Skip to content

State

Since 1.4.0

State definition for state machines.

Signature

typescript
interface State<S extends string, Data = object> { state: S, data: Data }

Parameters

ParameterDescription
SState name
DataOptional state data

Description

Represents a state in the state machine with optional data.

Examples

Basic Usage

typescript
import type { State } from 'uni-types'

type Loading = State<'loading', { progress: number }>
// { state: 'loading'; data: { progress: number } }

type Idle = State<'idle'>
// { state: 'idle'; data: object }

Released under the MIT License.