A shapeless-powered, typed variant of the actor/props creation.
A shapeless-powered, typed variant of the actor/props creation.
This is an alternative over constructors, that use the Class[A], Any*
overload to create actors.
You must use TypedActor
s and these actors must be case class
es for
this to work.
Example:
case class ExampleActor(foo: Option[String]) extends TypedActor.Of[String] { def typedReceive: TypedReceive = ??? } // runtime error (IllegalArgumentException: no matching constructor found): val runtimeError: ActorRef[String] = ActorOf(PropsOf[String](classOf[ExampleActor1], "wrong type")) // compiletime error: // found : String("wrong type") :: HNil // required: Option[String] :: HNil val compiletimeError: ActorRef[String] = Typed[ExampleActor2].create("wrong type")
Use apply with the TypedActor
as the type parameter and then call either
create
or props
with the appropriate constructor parameters to create
either an ActorRef or a Props.