如何在 Akka FSM 中的转换期间访问状态
我正在使用 Akka FSM 来处理 Actor 中的状态。我希望每次转换到某个状态时都执行一些操作,无论转换是从哪个状态进行的。阅读文档后,我确信可以这样解决:
onTransition({
case (_, ToState) => performAction(stateData)
})
...
when(FromState){
case "changestate" => goto(ToState) using NewStateData
}
但是,当发生转换时,stateData 尚未更新为 NewStateData。
进入某种状态时执行操作的推荐方法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您提请我注意这一点,这确实是一个疏忽,我立即修复了它(请参阅 票证)。不幸的是,在 1.3 版本发布(应该是下周)之前你无能为力(除了自己合并小补丁之外);如果您特别不耐烦,我将不胜感激,如果您可以尝试 RC2 以及本周将发布的修复程序。
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.