Skip to content

Instantly share code, notes, and snippets.

@adamw
Created June 10, 2018 18:20
Show Gist options
  • Save adamw/e261d83b5ebd2bb314a3ec7310dda3e1 to your computer and use it in GitHub Desktop.
Save adamw/e261d83b5ebd2bb314a3ec7310dda3e1 to your computer and use it in GitHub Desktop.
def handleMessage(consumers: Set[ActorRef[String]]): Behavior[BroadcastActorMessage] =
Behaviors.receiveMessage {
case Subscribe(actor) => handleMessage(consumers + actor)
case Received(msg) =>
consumers.foreach(_ ! msg)
handleMessage(consumers)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment