You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2024/09/01 05:49:13 UTC

Re: [PR] feat: avoid nesting in Behavior Factories [pekko]

He-Pin commented on code in PR #1459:
URL: https://github.com/apache/pekko/pull/1459#discussion_r1739979730


##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/Behaviors.scala:
##########
@@ -269,6 +280,19 @@ object Behaviors {
   def withTimers[T](factory: TimerScheduler[T] => Behavior[T]): Behavior[T] =
     TimerSchedulerImpl.withTimers(factory)
 
+  /**
+   * Support for scheduled `self` messages in an actor.
+   * It takes care of the lifecycle of the timers such as cancelling them when the actor
+   * is restarted or stopped.
+   *
+   * @see [[TimerScheduler]]
+   * @since 1.1.0
+   */
+  def withTimersSetup[T](factory: (TimerScheduler[T], ActorContext[T]) => Behavior[T]): Behavior[T] =
+    setup(ctx => {
+      TimerSchedulerImpl.withTimers(factory(_, ctx))
+    })

Review Comment:
   It was timer box setup but not now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org