-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaudit.rs
More file actions
30 lines (26 loc) · 630 Bytes
/
Copy pathaudit.rs
File metadata and controls
30 lines (26 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use perro_api::prelude::*;
#[State]
struct PatternAudit {
#[default = 0]
last_score: i32,
#[default = 0]
event_count: i32,
}
lifecycle!({
fn on_all_init(&self, ctx: &mut ScriptContext<'_, API>) {
signal_connect!(
ctx.run,
ctx.id,
signal!("score_changed"),
func!("record_score")
);
}
});
methods!({
pub fn record_score(&self, ctx: &mut ScriptContext<'_, API>, score: i32) {
with_state_mut!(ctx.run, PatternAudit, ctx.id, |state| {
state.last_score = score;
state.event_count += 1;
});
}
});