Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Dec 13, 2023
1 parent 42c5511 commit 07c0f93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,10 +37,12 @@ impl Object for Counter {}

impl Signal<i32> for Counter {}

impl Handler<i32> for Counter {
impl Slot<i32> for Counter {
fn handle(&mut self, cx: Context<Self>, msg: i32) {
self.value = msg;
cx.emit(msg);
if self.value != msg {
self.value = msg;
cx.emit(msg);
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions examples/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ impl Signal<i32> for Counter {}

impl Slot<i32> for Counter {
fn handle(&mut self, cx: Context<Self>, msg: i32) {
self.value = msg;
cx.emit(msg);
if self.value != msg {
self.value = msg;
cx.emit(msg);
}
}
}

Expand Down

0 comments on commit 07c0f93

Please sign in to comment.