diff --git a/README.md b/README.md index 174f41a4..36bf328c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Concoct is a runtime for user-interfaces in Rust. ```rust -use concoct::{Context, Handler, Object, Runtime, Signal}; +use concoct::{Context, Object, Runtime, Signal, Slot}; #[derive(Default)] pub struct Counter { @@ -37,10 +37,12 @@ impl Object for Counter {} impl Signal for Counter {} -impl Handler for Counter { +impl Slot for Counter { fn handle(&mut self, cx: Context, msg: i32) { - self.value = msg; - cx.emit(msg); + if self.value != msg { + self.value = msg; + cx.emit(msg); + } } } diff --git a/examples/counter.rs b/examples/counter.rs index 9cc21fc8..50991910 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -11,8 +11,10 @@ impl Signal for Counter {} impl Slot for Counter { fn handle(&mut self, cx: Context, msg: i32) { - self.value = msg; - cx.emit(msg); + if self.value != msg { + self.value = msg; + cx.emit(msg); + } } }