Last active
January 3, 2021 17:52
-
-
Save MartinKavik/cec56ee1d62aa41e817b4ba66aa41a14 to your computer and use it in GitHub Desktop.
zoon - draft - counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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