We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embrace a more Kotlinish style, letting the KBehavior type be defined as follows:
KBehavior
object MainActor { val behavior: KkBehavior<Int> = setup { val counterRef = ctx.spawn("counter", Counter.behavior(0)) counterRef `!` Counter.Increment(40) counterRef `!` Counter.Increment(2) ctx.log.info("Getting the value of the counter") counterRef `!` Counter.GetValue(ctx.self) counterRef `!` Counter.Reset counterRef `!` Counter.GetValue(ctx.self) receive { ctx.log.info("The counter value is $msg") same() } } } object Counter { sealed interface Command data class Increment(val by: Int) : Command object Reset : Command data class GetValue(val replyTo: KActorRef<Int>) : Command fun behavior(currentValue: Int): KkBehavior<Command> = receive { when (msg) { is Increment -> behavior(currentValue + msg.by) is Reset -> behavior(0) is GetValue -> { msg.replyTo `!` currentValue same() } } } }
The ctx and msg should be implicitly available in the setup and receive factory methods.
ctx
msg
setup
receive
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Embrace a more Kotlinish style, letting the
KBehavior
type be defined as follows:The
ctx
andmsg
should be implicitly available in thesetup
andreceive
factory methods.The text was updated successfully, but these errors were encountered: