Get rid of the context in properties/signal

This commit is contained in:
Olivier Goffart 2020-07-13 18:49:06 +02:00
parent ab7ae9f3e2
commit e00491811b
25 changed files with 389 additions and 653 deletions

View file

@ -4,16 +4,17 @@ sixtyfps::include_modules!();
fn main() {
let app = Hello::new();
app.plus_clicked.set_handler(|context, ()| {
let app = context.get_component::<Hello>().unwrap();
let counter = Hello::field_offsets().counter.apply_pin(app);
counter.set(counter.get(context) + 1);
let app_weak = sixtyfps::re_exports::WeakPin::downgrade(app.clone());
app.plus_clicked.set_handler(move |()| {
let app = app_weak.upgrade().unwrap();
let counter = Hello::field_offsets().counter.apply_pin(app.as_ref());
counter.set(counter.get() + 1);
});
app.minus_clicked.set_handler(|context, ()| {
let app = context.get_component::<Hello>().unwrap();
let counter = Hello::field_offsets().counter.apply_pin(app);
counter.set(counter.get(context) - 1);
let app_weak = sixtyfps::re_exports::WeakPin::downgrade(app.clone());
app.minus_clicked.set_handler(move |()| {
let app = app_weak.upgrade().unwrap();
let counter = Hello::field_offsets().counter.apply_pin(app.as_ref());
counter.set(counter.get() - 1);
});
app.run();
}