-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabi Volpe
committed
Aug 4, 2016
0 parents
commit 1bb29cb
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
*# | ||
*.iml | ||
*.ipr | ||
*.iws | ||
*.pyc | ||
*.tm.epoch | ||
*.vim | ||
*/project/boot | ||
*/project/build/target | ||
*/project/project.target.config-classes | ||
*-shim.sbt | ||
*~ | ||
.#* | ||
.*.swp | ||
.DS_Store | ||
.cache | ||
.cache | ||
.classpath | ||
.codefellow | ||
.ensime* | ||
.eprj | ||
.history | ||
.idea | ||
.manager | ||
.multi-jvm | ||
.project | ||
.scala_dependencies | ||
.scalastyle | ||
.settings | ||
.tags | ||
.tags_sorted_by_file | ||
.target | ||
.worksheet | ||
Makefile | ||
TAGS | ||
lib_managed | ||
logs | ||
project/boot/* | ||
project/plugins/project | ||
src_managed | ||
target | ||
tm*.lck | ||
tm*.log | ||
tm.out | ||
worker*.log | ||
/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
typed-actors-demo | ||
================= | ||
|
||
Simple demo using [Typed Actors](https://github.com/knutwalker/typed-actors). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name := """typed-actors-demo""" | ||
|
||
version := "1.0" | ||
|
||
scalaVersion := "2.11.8" | ||
|
||
libraryDependencies ++= List( | ||
"com.typesafe.akka" %% "akka-actor" % "2.4.9-RC1", | ||
"de.knutwalker" %% "typed-actors" % "1.6.0", | ||
"de.knutwalker" %% "typed-actors-creator" % "1.6.0" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=0.13.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.gvolpe.typed | ||
|
||
import akka.actor._ | ||
import de.knutwalker.akka.typed._ | ||
import com.gvolpe.typed.actor.TypedActorExample | ||
import com.gvolpe.typed.actor.TypedActorExample.{Bar, Foo} | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.duration._ | ||
|
||
object Demo extends App { | ||
|
||
implicit val system = ActorSystem("typed-actors-demo") | ||
|
||
case object SomeOtherMessage | ||
|
||
val actor = TypedActorExample.props | ||
|
||
actor ! Foo("Hey you!") | ||
actor ! Bar("What's the craic?") | ||
|
||
// You'll get a compilation error! | ||
//actor ! SomeOtherMessage | ||
|
||
system.scheduler.scheduleOnce(2.seconds)(system.terminate()) | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/scala/com/gvolpe/typed/actor/TypedActorExample.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.gvolpe.typed.actor | ||
|
||
import akka.actor.{Actor, ActorSystem} | ||
import de.knutwalker.akka.typed._ | ||
import com.gvolpe.typed.actor.TypedActorExample._ | ||
|
||
object TypedActorExample { | ||
sealed trait MyMessage | ||
case class Foo(foo: String) extends MyMessage | ||
case class Bar(bar: String) extends MyMessage | ||
|
||
def props(implicit s: ActorSystem) = ActorOf(Props[MyMessage, TypedActorExample], name = "typed-actor") | ||
} | ||
|
||
class TypedActorExample extends Actor { | ||
override def receive: Receive = { | ||
case Foo(foo) => println(s"received a Foo: $foo") | ||
case Bar(bar) => println(s"received a Bar: $bar") | ||
} | ||
} |