mirror of
https://github.com/danbulant/cushy
synced 2026-05-21 13:18:48 +00:00
Closes #98 This finishes my initial refactoring of the dynamic system to add support for several dataflows including: - Pure data sources that can be implemented using an `Owned<T>` at the root of a graph of `Dynamic<U>`/`DynamicReader<U>`s. - Read-only data sinks. I thought this would be more useful across other widgets, but in general, Progress and Label seem like the only types that this applies to currently. - The ability to mix/match Dynamic/DynamicReader in tuple-based for_each/map_each.
21 lines
618 B
Rust
21 lines
618 B
Rust
use cushy::value::{Destination, Dynamic, IntoReader, Source};
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::Run;
|
|
|
|
// begin rustme snippet: readme
|
|
fn main() -> cushy::Result {
|
|
// Create a dynamic usize.
|
|
let count = Dynamic::new(0_isize);
|
|
|
|
// Create a new label displaying `count`
|
|
count
|
|
.clone()
|
|
.into_label()
|
|
// Use the label as the contents of a button
|
|
.into_button()
|
|
// Set the `on_click` callback to a closure that increments the counter.
|
|
.on_click(move |_| count.set(count.get() + 1))
|
|
// Run the application
|
|
.run()
|
|
}
|
|
// end rustme snippet
|