Behaviour transition functionality

(Christopher Hunt) #1

I’d really like to be able to specify a function that is evaluated when transitioning from one behaviour to another in Akka Typed, particularly when expressing an FSM. Is this possible?

(Patrik Nordwall) #2

Could you describe more about why you need it, so I understand better.

Typically you create the new behavior by calling a method that returns the new behavior. Can’t you do the transition logic in those methods?

If you are looking for a general purpose solution it should be possible to implement such transition listener in a BehaviorInterceptor. Looking at the returned behavior to see if it’s Behaviors.same or not.

(Christopher Hunt) #3

Thanks Patrik!

I was looking for something similar to the untyped FSM where transitional behaviour can be specified. I wasn’t aware of the interceptor functionality. Is there some doc or an example?

(Patrik Nordwall) #4

A nice example can be found in PR #26238 for logging messages