Closed captainmannering closed 4 years ago
Hi @captainmannering Are you wondering how one can use an Akka Typed Actor with this project? If so can you post some more details about the issues you're facing?
Regarding documentation, I'll happily consider a PR.
Maybe I am just thinking about it the wrong way, but for this method signature in the documentation:
def schedule(name: String, receiver: ActorRef, msg: AnyRef, startDate: Option[Date])
What if I have a typed actor instead? Is there a way to call schedule with types like this?..
sealed trait MyMessages
case object Tick extends MyMessages
def schedule(name: String, receiver: ActorRef[MyMessages], msg: Tick, startDate: Option[Date])
?
If I'm not mistaken, you should still be able to call the first definition of schedule
as you have it listed there. Can you try that? Do you get any kind of error?
You can convert a typed ActorRef[T]
to a classic (untyped) ActorRef
like this:
// this pulls e.g. an implicit .toClassic into scope
import akka.actor.typed.scaladsl.adapter._
sealed trait MyMessages
case object Tick extends MyMessages
val ref : ActorRef[MyMessages] = ???
scheduler.schedule("daily", ref.toClassic, Tick)
More on that: https://doc.akka.io/docs/akka/current/typed/coexisting.html#typed-to-classic
@captainmannering Does that resolve your issue?
Yes! thanks!
Could the documentation be updated to give a simple example of having an Akka Typed Actor directly be the recipient of the message rather than a classic Actor?