Skip to content

Commit

Permalink
fix(fsm): action maybe async
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Mar 18, 2023
1 parent 021a234 commit 50efffa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/fsm/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
FsmTypeHelper,
SignalConfig,
} from './type.js';
import type {OmitFirstParam, SingleOrArray, StringifyableRecord} from '@alwatr/type';
import type {MaybePromise, OmitFirstParam, SingleOrArray, StringifyableRecord} from '@alwatr/type';

globalAlwatr.registeredList.push({
name: '@alwatr/fsm',
Expand Down Expand Up @@ -199,7 +199,7 @@ export const _execAction = (
constructor: FsmConstructor,
actionNames: SingleOrArray<string> | undefined,
finiteStateMachine: FsmConsumerInterface,
): boolean | void => {
): boolean | MaybePromise<void> => {
if (actionNames == null) return;
logger.logMethodArgs('execAction', {constructorId: constructor.id, actionNames});

Expand Down
4 changes: 2 additions & 2 deletions core/fsm/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {finiteStateMachineConsumer} from './core.js';
import type {DebounceType} from '@alwatr/signal';
import type {ArrayItems, SingleOrArray, StringifyableRecord} from '@alwatr/type';
import type {ArrayItems, MaybePromise, SingleOrArray, StringifyableRecord} from '@alwatr/type';

export interface FsmConstructor {
/**
Expand Down Expand Up @@ -107,7 +107,7 @@ export interface FsmInstance<
}

export type ActionRecord<T extends FsmTypeHelper = FsmTypeHelper> = {
readonly [P in T['TActionName']]?: (finiteStateMachine: FsmConsumerInterface<T>) => void | boolean;
readonly [P in T['TActionName']]?: (finiteStateMachine: FsmConsumerInterface<T>) => MaybePromise<void> | boolean;
};

export type SignalConfig<T extends FsmTypeHelper = FsmTypeHelper> = {
Expand Down

0 comments on commit 50efffa

Please sign in to comment.