Skip to content

Instantly share code, notes, and snippets.

@diogoaurelio
Created December 20, 2017 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogoaurelio/b469e5c6531e9b9f6b35cb8456292766 to your computer and use it in GitHub Desktop.
Save diogoaurelio/b469e5c6531e9b9f6b35cb8456292766 to your computer and use it in GitHub Desktop.
Basic Scala Actor Class
import akka.actor.Actor
import akka.actor.Props
import akka.event.Logging
class MyActor extends Actor {
val log = Logging(context.system, this)
var myMutatedVar: Int = 0
def receive = {
case "test" => log.info("received test")
case "mutate" => myMutatedVar += 1; log.info(s"Mutated var to: $myMutatedVar")
case _ => log.info("received unknown message")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment