mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Use intermediate type for the callback promise
Using actual promises would still be better
This commit is contained in:
parent
c1c9322319
commit
5e6222bf23
@ -7,15 +7,19 @@ use event::*;
|
|||||||
use theme::ColorStyle;
|
use theme::ColorStyle;
|
||||||
use view::View;
|
use view::View;
|
||||||
|
|
||||||
|
pub type CbPromise = Option<Box<Fn(&mut Cursive) + Send>>;
|
||||||
|
|
||||||
/// Display progress.
|
/// Display progress.
|
||||||
pub struct ProgressBar {
|
pub struct ProgressBar {
|
||||||
min: usize,
|
min: usize,
|
||||||
max: usize,
|
max: usize,
|
||||||
value: Arc<AtomicUsize>,
|
value: Arc<AtomicUsize>,
|
||||||
// TODO: use a Promise instead?
|
// TODO: use a Promise instead?
|
||||||
callback: Option<Arc<Mutex<Option<Box<Fn(&mut Cursive) + Send>>>>>,
|
callback: Option<Arc<Mutex<CbPromise>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_default!(ProgressBar);
|
||||||
|
|
||||||
impl ProgressBar {
|
impl ProgressBar {
|
||||||
/// Creates a new progress bar.
|
/// Creates a new progress bar.
|
||||||
///
|
///
|
||||||
@ -43,7 +47,7 @@ impl ProgressBar {
|
|||||||
///
|
///
|
||||||
/// Whenever `callback` is set, it will be called on the next event loop.
|
/// Whenever `callback` is set, it will be called on the next event loop.
|
||||||
pub fn with_callback(mut self,
|
pub fn with_callback(mut self,
|
||||||
callback: Arc<Mutex<Option<Box<Fn(&mut Cursive) + Send>>>>)
|
callback: Arc<Mutex<CbPromise>>)
|
||||||
-> Self {
|
-> Self {
|
||||||
self.callback = Some(callback);
|
self.callback = Some(callback);
|
||||||
self
|
self
|
||||||
|
Loading…
Reference in New Issue
Block a user