pub fn emit_event<E: Event>(&self, event: E) -> Result<(), EventManagerError> {
        self.channels.get(&TypeId::of::<E>()).map_or_else(
            || Err(EventManagerError::ChannelNotExist),
            |ec| {
                unsafe {
                    ec.downcast_ref_unchecked::<EventChannel<E>>()
                        .s
                        .send(event)
                        .unwrap()
                }
                Ok(())
            },
        )
    }
/// Emit an event to given system.
///
/// # Safety
/// It is safe to emit events to other systems concurrently because [EventChannel] uses
/// crossbeam-channel internally which is Send + Sync.
Emit an event to given system.
Emit an event to given system .
pub fn emit_event<E: Event>(&self, event: E) -> Result<(), EventManagerError> {
        self.channels.get(&TypeId::of::<E>()).map_or_else(
            || Err(EventManagerError::ChannelNotExist),
            |ec| {
                unsafe {
                    ec.downcast_ref_unchecked::<EventChannel<E>>()
                        .s
                        .send(event)
                        .unwrap()
                }
                Ok(())
            },
        )
    }
pub fn emit_event < E : Event > ( & self , event : E ) -> Result < ( ) , EventManagerError > { self . channels . get ( & TypeId :: of :: < E > ( ) ) . map_or_else ( | | Err ( EventManagerError :: ChannelNotExist ) , | ec | { unsafe { ec . downcast_ref_unchecked :: < EventChannel < E > > ( ) . s . send ( event ) . unwrap ( ) } Ok ( ( ) ) } , ) }
Emit an event to given system.
Emit an event to given system .
&self
event
E
&self
event
E
safety
It is safe to emit events to other systems concurrently because [EventChannel] uses
crossbeam-channel internally which is Send + Sync.
It is safe to emit events to other systems concurrently because [ EventChannel ] uses crossbeam - channel internally which is Send + Sync .