pub async fn new(
        model: Weak<Model>,
        target_moniker: AbsoluteMoniker,
        registry: &Arc<EventRegistry>,
        sync_mode: SyncMode,
    ) -> Result<Self, ModelError> {
        // TODO(fxb/48245): this shouldn't be done for any EventSource. Only for tests.
        let resolve_instance_event_stream = Arc::new(Mutex::new(if sync_mode == SyncMode::Async {
            None
        } else {
            Some(
                registry
                    .subscribe(
                        &sync_mode,
                        vec![RoutedEvent {
                            source_name: EventType::Resolved.into(),
                            scope_monikers: hashset!(target_moniker.clone()),
                        }],
                    )
                    .await,
            )
        }));
        Ok(Self {
            registry: Arc::downgrade(&registry),
            model,
            target_moniker,
            resolve_instance_event_stream,
            debug: false,
            sync_mode,
        })
    }
/// Creates a new `EventSource` that will be used by the component identified with the given
/// `target_moniker`.
Creates a new `EventSource` that will be used by the component identified with the given
`target_moniker`.
Creates a new ` EventSource ` that will be used by the component identified with the given ` target_moniker ` .
pub async fn new(
        model: Weak<Model>,
        target_moniker: AbsoluteMoniker,
        registry: &Arc<EventRegistry>,
        sync_mode: SyncMode,
    ) -> Result<Self, ModelError> {
        // TODO(fxb/48245): this shouldn't be done for any EventSource. Only for tests.
        let resolve_instance_event_stream = Arc::new(Mutex::new(if sync_mode == SyncMode::Async {
            None
        } else {
            Some(
                registry
                    .subscribe(
                        &sync_mode,
                        vec![RoutedEvent {
                            source_name: EventType::Resolved.into(),
                            scope_monikers: hashset!(target_moniker.clone()),
                        }],
                    )
                    .await,
            )
        }));
        Ok(Self {
            registry: Arc::downgrade(&registry),
            model,
            target_moniker,
            resolve_instance_event_stream,
            debug: false,
            sync_mode,
        })
    }
pub async fn new ( model : Weak < Model > , target_moniker : AbsoluteMoniker , registry : & Arc < EventRegistry > , sync_mode : SyncMode , ) -> Result < Self , ModelError > { // TODO(fxb/48245): this shouldn't be done for any EventSource. Only for tests. let resolve_instance_event_stream = Arc :: new ( Mutex :: new ( if sync_mode == SyncMode :: Async { None } else { Some ( registry . subscribe ( & sync_mode , vec ! [ RoutedEvent { source_name EventType Resolved into ( ) scope_monikers hashset ( target_moniker clone ( ) ) } ] , ) . await , ) } ) ) ; Ok ( Self { registry : Arc :: downgrade ( & registry ) , model , target_moniker , resolve_instance_event_stream , debug : false , sync_mode , } ) }
Creates a new `EventSource` that will be used by the component identified with the given
`target_moniker`.
Creates a new ` EventSource ` that will be used by the component identified with the given ` target_moniker ` .
model
Weak<Model>
target_moniker
AbsoluteMoniker
registry
&Arc<EventRegistry>
sync_mode
SyncMode
model
Weak<Model>
target_moniker
AbsoluteMoniker
registry
&Arc<EventRegistry>
sync_mode
SyncMode