Yup, the function makes sense.
And yes I assume the all transition blocks occur (thats why I have put two handlers there, not single one). The desired functionality is to do the cleanup in A->_ case (essentially saying do this always for everyone leaving the A state) and then do some notifications or cleanup or whatever in A->B and A->C ... This may be much more clear to read than all these def clearNone().andThenSetSome() ... chains. I think it is style of preference maybe.
Just think of this like more clear way of expresing the intentions
//Always when leaving state make sure data are consistent and put all assertions here
onTransition {
case A-> _ => //do cleanup
}
//when entering state make sure all data are consistent and do all assertions
onTransition {
case _ -> A => //do initialization
}
when (A) {
case Event(msg:MsgOne, data) => {
goto(B).assureADataAreSetCorrectly().using (....)
}
....... many more messages where I may go to B, C, D, E, F and everywhere I have to repeat goto(XYZ).assureADataAreSetCorrectly()
}
def assureADataAreSetCorrectly()
I can live without it, but would not believe there is a big deal to have this feature in. looking on what def nextState is, I think def nextState_= would solve the problem. In fact you can have this if one prefer having vars holding these state data, but this seems to me broken as this tights the implementation to actual instance and may be prolly broken design when migrating state actors over cluster in future....
Cheers, and thanks for suggestion
Pavel.