/// Launch component with url and optional arguments and detach directly
/// # Arguments
/// * `args`: will be parsed to LaunchRequest in create_launch_app
/// * `url`: url of the component
/// * `arguments`: optional arguments for the component
Launch component with url and optional arguments and detach directly
Launch component with url and optional arguments and detach directly
pub async fn launch(&self, args: Value) -> Result<LaunchResult, Error> {
        let tag = "LaunchFacade::launch";
        let launch_app = Some(self.create_launch_app(args).await?);
        let app = match launch_app {
            Some(p) => p,
            None => fx_err_and_bail!(&with_line!(tag), "Failed to launch component."),
        };
        let mut component_stream = app.controller().take_event_stream();
        match component_stream
            .next()
            .await
            .expect("component event stream ended before termination event")?
        {
            // detach if succeeds
            ComponentControllerEvent::OnDirectoryReady {} => {
                app.controller().detach()?;
            }
            // if there's exception (like url package not found, return fail)
            ComponentControllerEvent::OnTerminated { return_code, termination_reason } => {
                bail!(
                    "Component terminated unexpectedly. Code: {}. Reason: {:?}",
                    return_code,
                    termination_reason
                );
            }
        }
        Ok(LaunchResult::Success)
    }
pub async fn launch ( & self , args : Value ) -> Result < LaunchResult , Error > { let tag = " " ; let launch_app = Some ( self . create_launch_app ( args ) . await ? ) ; let app = match launch_app { Some ( p ) => p , None => fx_err_and_bail ! ( with_line ( tag ) " " ) , } ; let mut component_stream = app . controller ( ) . take_event_stream ( ) ; match component_stream . next ( ) . await . expect ( " " ) ? { // detach if succeeds ComponentControllerEvent :: OnDirectoryReady { } => { app . controller ( ) . detach ( ) ? ; } // if there's exception (like url package not found, return fail) ComponentControllerEvent :: OnTerminated { return_code , termination_reason } => { bail ! ( " " return_code termination_reason ) ; } } Ok ( LaunchResult :: Success ) }
Launch component with url and optional arguments and detach directly
Launch component with url and optional arguments and detach directly
&self
args
Value