Skip to content

uni-flow 公开 API(中文注解)


uni-flow 公开 API(中文注解) / InMemorySharedState

Class: InMemorySharedState

Defined in: core/shared-state.ts:18

进程内 SharedState 实现:带 scope 前缀的键值存储、快照与简单事务。

一般通过 createSharedState 获取,无需直接 new

Implements

Constructors

Constructor

new InMemorySharedState(): InMemorySharedState

Returns

InMemorySharedState

Methods

delete()

delete(key): void

Defined in: core/shared-state.ts:37

删除键。

Parameters

key

string

Returns

void

Implementation of

SharedState.delete


get()

get<T>(key): T | undefined

Defined in: core/shared-state.ts:22

读取工作流 scope 下的键。

Type Parameters

T

T

Parameters

key

string

Returns

T | undefined

Implementation of

SharedState.get


has()

has(key): boolean

Defined in: core/shared-state.ts:42

是否存在键。

Parameters

key

string

Returns

boolean

Implementation of

SharedState.has


restore()

restore(snapshot): void

Defined in: core/shared-state.ts:110

Parameters

snapshot

Record<string, unknown>

Returns

void


scope()

scope(level): ScopedStateView

Defined in: core/shared-state.ts:59

进入指定 scope 的视图。

Parameters

level

StateScope

Returns

ScopedStateView

Implementation of

SharedState.scope


set()

set<T>(key, value): void

Defined in: core/shared-state.ts:26

写入工作流 scope 下的键。

Type Parameters

T

T

Parameters

key

string

value

T

Returns

void

Implementation of

SharedState.set


snapshot()

snapshot(): Record<string, unknown>

Defined in: core/shared-state.ts:46

导出当前快照(扁平对象)。

Returns

Record<string, unknown>

Implementation of

SharedState.snapshot


transaction()

transaction(fn): void

Defined in: core/shared-state.ts:85

在事务中批量变更(冲突时可能抛错,视实现而定)。

Parameters

fn

(tx) => void

Returns

void

Implementation of

SharedState.transaction

MIT Licensed