forked from SoniEx2/rust.eventbus
collate cancelled
This commit is contained in:
parent
3c3e8754ad
commit
fedb32d242
|
@ -72,7 +72,6 @@ macro_rules! post_event {
|
|||
fun(event);
|
||||
}
|
||||
},)+); // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +96,7 @@ macro_rules! post_event_cancellable {
|
|||
}
|
||||
|
||||
test(event);
|
||||
let cancelled = ($({
|
||||
let cancelled = [$({
|
||||
// event type setup
|
||||
static EVENT_ID: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
|
||||
static EVENT_ID_INIT: ::std::sync::Once = ::std::sync::ONCE_INIT;
|
||||
|
@ -110,15 +109,16 @@ macro_rules! post_event_cancellable {
|
|||
let handlers = $crate::get_post_targets::<$t>(bus, event, id);
|
||||
|
||||
for (_pri, fun) in handlers.iter() {
|
||||
fun(event as &mut $t);
|
||||
if Cancellable::cancelled(event) {
|
||||
break;
|
||||
}
|
||||
fun(event as &mut $t);
|
||||
}
|
||||
|
||||
event.cancelled()
|
||||
},)+); // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
||||
},)+]; // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
||||
|
||||
cancelled.iter().fold(false, |n, i| n || *i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue