Fixed refresh
This commit is contained in:
@@ -29,8 +29,11 @@ fn app(cx: &Arc<Context>) -> View {
|
|||||||
let count = count.clone();
|
let count = count.clone();
|
||||||
move |_cx, _event: &KeyPress| {
|
move |_cx, _event: &KeyPress| {
|
||||||
let mut count = count.get();
|
let mut count = count.get();
|
||||||
|
if *count > 5 {
|
||||||
|
_cx.refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
*count += 1;
|
*count += 1;
|
||||||
cx.refresh();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh(self: &Arc<Context>) {
|
pub fn refresh(self: &Arc<Context>) {
|
||||||
|
self.event_handlers.lock().unwrap().clear();
|
||||||
|
|
||||||
let c = self.component.lock().unwrap().clone();
|
let c = self.component.lock().unwrap().clone();
|
||||||
*self.view.lock().unwrap() = (c)(self);
|
*self.view.lock().unwrap() = (c)(self);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user