Skip to content

Commit

Permalink
fix(fsm): last reported bugs in set state
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Mar 17, 2023
1 parent 224799c commit e7435c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/fsm/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ export class FiniteStateMachine<
TEventId extends string = string,
TContext extends StringifyableRecord = StringifyableRecord
> {
state: StateContext<TState, TEventId> = this.setState(this.config.initial, 'INIT');

context = this.config.context;

signal = contextConsumer.bind<StateContext<TState, TEventId>>('finite-state-machine-' + this.config.id);
signal = contextConsumer.bind<StateContext<TState, TEventId>>('finite_state_machine_' + this.config.id);

protected _logger = createLogger(`alwatr/fsm:${this.config.id}`);

state: StateContext<TState, TEventId> = this.setState(this.config.initial, 'INIT');

protected setState(target: TState, by: TEventId | 'INIT'): StateContext<TState, TEventId> {
const state: StateContext<TState, TEventId> = (this.state = {
target,
from: this.signal.getValue()?.target ?? target,
from: this.signal?.getValue()?.target ?? target,
by,
});

dispatch<StateContext<TState, TEventId>>(this.signal.id, state, {debounce: 'NextCycle'});

this.execAllActions().catch((err) => this._logger.error('myMethod', 'error_code', err));
setTimeout(() => this.execAllActions(), 0);

return state;
}
Expand Down

0 comments on commit e7435c8

Please sign in to comment.