| Name | Type |
|---|---|
ARG |
ARG |
DATA |
void |
new Action<ARG, DATA>(actionExecutor, scope?)
| Name | Type |
|---|---|
ARG |
ARG |
DATA |
void |
| Name | Type |
|---|---|
actionExecutor |
(args: ARG) => PromiseOrValue<ActionExecutorReturnType<DATA>> |
scope? |
Scope |
Private _arg: any
最近一次执行的参数,目前还没有增加自动清理机制,有很小可能会造成内存泄漏
Private _error: any
Private _state: any
Private Readonly actionExecutor: any
Private Readonly eventFailedTriggers: any
Private Readonly eventSuccessTriggers: any
Private Readonly scope: any
Private setFailed: any
Private setResult: any
Private triggerEvents: any
get arg(): undefined | ARG
undefined | ARG
get error(): unknown
unknown
get isFailed(): boolean
boolean
get isRunning(): boolean
boolean
get state(): ActionState
ActionState
run(...args): boolean | Promise<boolean>
| Name | Type |
|---|---|
...args |
ARG extends void ? [] : [ARG] |
boolean | Promise<boolean>
runOn<EVENT>(eventRegistry, mapper, filter?): () => void
将当前的Action与一个事件关联起来。当事件触发时,将执行此Action。
| Name |
|---|
EVENT |
| Name | Type | Description |
|---|---|---|
eventRegistry |
EventRegistry<EVENT> |
事件注册器 |
mapper |
(event: EVENT) => ARG |
事件到Action参数的映射函数 |
filter? |
(event: EVENT) => boolean |
事件过滤函数,返回false表示不执行Action |
fn
取消函数
(): void
将当前的Action与一个事件关联起来。当事件触发时,将执行此Action。
void
取消函数
triggersDoneEvent(eventSource, condition?): void
| Name | Type |
|---|---|
eventSource |
EventRegistry<DATA> |
condition? |
(data: DATA) => boolean |
void
triggersDoneEventWithMapper<EVENT>(eventSource, mapper, condition?): void
| Name |
|---|
EVENT |
| Name | Type |
|---|---|
eventSource |
EventRegistry<EVENT> |
mapper |
(data: DATA, arg: ARG) => EVENT |
condition? |
(data: DATA) => boolean |
void
triggersFailedEvent<T>(eventSource, mapper, condition?): void
| Name |
|---|
T |
| Name | Type |
|---|---|
eventSource |
EventRegistry<T> |
mapper |
(reason: unknown, arg: ARG) => T |
condition? |
(reason: unknown) => boolean |
void