In classical programming, I use the obeserver pattern in case I want to notify observers about changes.
What is the equivalent pattern in Akka?
Use case:
Take a look at BroadcastGroup
//Create group
val paths = List("/user/workers/w1", "/user/workers/w2", "/user/workers/w3")
val observers: ActorRef = context.actorOf(BroadcastGroup(paths).props(), "observers")
To notify all observers just send message to observers
ActorRef. Also you can add and remove observers by sending akka.routing.AddRoutee
and akka.routing.RemoveRoutee
.
You can find more routing docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With