Skip to content

Instantly share code, notes, and snippets.

@MartinKavik
Last active January 3, 2021 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinKavik/cec56ee1d62aa41e817b4ba66aa41a14 to your computer and use it in GitHub Desktop.
Save MartinKavik/cec56ee1d62aa41e817b4ba66aa41a14 to your computer and use it in GitHub Desktop.
zoon - draft - counter
use zoon::*;
blocks!{
#[s_var]
fn counter() -> i32 {
0
}
#[update]
fn increment() {
counter().update(|counter| counter + 1);
}
#[update]
fn decrement() {
counter().update(|counter| counter - 1);
}
#[el]
fn root() -> Column {
column![
button![button::on_press(decrement), "-"],
counter().inner(),
button![button::on_press(increment), "+"],
]
}
}
fn main() {
start!()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment