suprnation / cats-actors

Cats Actors framework for building apps which are reactive. Cats actors uses a conceptual actor model as a higher level abstraction for concurrency.
Apache License 2.0
80 stars 7 forks source link

fix: FSM - Termination - Added stateData and referenced correct state #14

Closed Mitrug closed 2 months ago

Mitrug commented 2 months ago

Description

  1. Added the StateData to the onTermination method in the FSMBuilder.
  2. Fixed issue with the FSM termination method using the previous state data instead of the next one.

Example FSM with updated onTermination method:

FSM[IO, FsmState, Int, FsmRequest, Any]
  .when(FsmIdle)(sM => { case Event(FsmStop, _) =>
    sM.stop(Normal, 0)
  })
  .withConfig(FSMConfig.withConsoleInformation)
  .onTermination {
    case (Normal, stateData) => ...
    case _ => ...
  }
  .startWith(startWith, 1)
  .initialize