Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access state during transitions in Akka FSM

I am using Akka FSM for handling state in my Actor. I want some actions to be performed every time a transition to a certain state occurs, no matter which state the transition was made from. After reading the docs, I felt certain that this could be resolved like this:

onTransition({
  case (_, ToState) => performAction(stateData)
})

...

when(FromState){
  case "changestate" => goto(ToState) using NewStateData
}

However, when the transition occurs, stateData is not yet updated to NewStateData.

What is the recommended way to perform actions on entering a certain state?

like image 938
eirirlar Avatar asked Nov 29 '11 11:11

eirirlar


1 Answers

Thanks for bringing this to my attention, that was indeed an oversight, which I fixed immediately (see the ticket). Unfortunately there is not much you can do (apart from merging in the tiny patch yourself) until 1.3 is out, which should be next week; if you are particularly impatient, I would appreciate if you could try out RC2 with the fix which will be released this week.

like image 191
Roland Kuhn Avatar answered Nov 17 '22 04:11

Roland Kuhn