runa/runa-std/actors/counter.rn

12 lines
335 B
Plaintext
Raw Permalink Normal View History

pub fn handle(ctx, state, sender, message) {
let state = match state { () => 0, state => state };
if message.op == "inc" {
let new_state = state + 1;
ctx.info(`New State: ${new_state}`);
ctx.send(ctx.this, #{op: "inc"});
new_state
} else {
panic("unknown counter operation")
}
}