Skip to content

Transition

自 1.4.0 起

状态机的转换定义。

签名

typescript
interface Transition<Event extends string, From extends string, To extends string> {
  event: Event
  from: From
  to: To
}

参数

参数描述
Event触发转换的事件名称
From源状态
To目标状态

描述

定义由事件触发的状态转换。

示例

基本用法

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

type NextTransition = Transition<'next', 'idle', 'loading'>
// { event: 'next'; from: 'idle'; to: 'loading' }

相关

基于 MIT 许可发布