From 9049d2c7677ab14b39cce9e269ceed149b4eaf42 Mon Sep 17 00:00:00 2001 From: Mohammad Honarvar Date: Fri, 2 Jun 2023 20:19:50 +0330 Subject: [PATCH] refactor(fsm2): extends from `AlwatrBaseSignal` --- core/fsm2/src/core.ts | 16 +++++++--------- core/fsm2/tsconfig.json | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/fsm2/src/core.ts b/core/fsm2/src/core.ts index 724ca77ae..fac59c6a6 100644 --- a/core/fsm2/src/core.ts +++ b/core/fsm2/src/core.ts @@ -1,12 +1,7 @@ -import {createLogger, globalAlwatr} from '@alwatr/logger'; +import {AlwatrBaseSignal} from '@alwatr/signal2'; import type {MaybePromise, SingleOrArray, Stringifyable} from '@alwatr/type'; -globalAlwatr.registeredList.push({ - name: '@alwatr/fsm', - version: _ALWATR_VERSION_, -}); - export type ActionFn = (this: unknown) => MaybePromise; export type ConditionFn = (this: unknown) => boolean; @@ -86,9 +81,11 @@ export type MachineConfig { - protected _logger = createLogger(`alwatr/fsm`); - +export class FiniteStateMachine< + Context extends Stringifyable, + StateName extends string, + EventName extends string +> extends AlwatrBaseSignal> { /** * Current state */ @@ -105,6 +102,7 @@ export class FiniteStateMachine, ) { + super('FiniteStateMachine', 'fsm'); this._logger.logMethodArgs?.('constructor', {_config}); this.context = _config.context; diff --git a/core/fsm2/tsconfig.json b/core/fsm2/tsconfig.json index e6c93f7e8..47ae5272a 100644 --- a/core/fsm2/tsconfig.json +++ b/core/fsm2/tsconfig.json @@ -12,6 +12,6 @@ "references": [ {"path": "../logger"}, {"path": "../type"}, - {"path": "../signal"}, + {"path": "../signal2"}, ] }