pub struct EventDispatcher { /* private fields */ }Expand description
Pengatur event yang mengelola pendaftaran listener dan pengiriman event.
Implementations§
Source§impl EventDispatcher
impl EventDispatcher
Sourcepub fn new() -> EventDispatcher
pub fn new() -> EventDispatcher
Membuat dispatcher baru.
Sourcepub fn listen<E>(&self, listener: Arc<dyn Listener>)where
E: Event + 'static,
pub fn listen<E>(&self, listener: Arc<dyn Listener>)where
E: Event + 'static,
Mendaftarkan listener untuk tipe event tertentu.
Sourcepub async fn dispatch<E>(&self, event: E, state: Arc<AppState>)
pub async fn dispatch<E>(&self, event: E, state: Arc<AppState>)
Mengirimkan event ke semua listener yang terdaftar secara asinkron.
Jika event mengimplementasikan ShouldBroadcast (via event.broadcaster()),
otomatis mem-broadcast via WebSocket/Echo.
Sourcepub fn dispatch_broadcast<B>(&self, broadcaster: &B, state: &AppState)where
B: ShouldBroadcast,
pub fn dispatch_broadcast<B>(&self, broadcaster: &B, state: &AppState)where
B: ShouldBroadcast,
Helper untuk langsung mem-broadcast event secara manual jika mengimplementasikan ShouldBroadcast.
Auto Trait Implementations§
impl !Freeze for EventDispatcher
impl Forget for EventDispatcher
impl Move for EventDispatcher
impl RefUnwindSafe for EventDispatcher
impl Send for EventDispatcher
impl Sync for EventDispatcher
impl Unpin for EventDispatcher
impl UnsafeUnpin for EventDispatcher
impl UnwindSafe for EventDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more