February 2018
Intermediate to advanced
552 pages
13h 46m
English
The following code snippet shows how to use ActorContext's become() and unbecome() functions:
class MyFSMActor extends Actor {
def receive = {
case Switch =>
become({
case Switch =>
unbecome()
})
}
}
Here, when SwapActor receives a switch message for first time, it changes its state to become. Then, if it receives the same message the next time, it moves to the unbecoming state.
Akka has a decent FSM DSL (Domain Specific Language) API to ease the development of FST Machines.
Read now
Unlock full access