Repository: DioxusLabs/dioxus
File: packages/cli/src/serve/output.rs (Rust)

Code before:
            _rustc_version,
            _rustc_nightly,
            _dx_version: dx_version,
            interactive,
            is_cli_release,
            platform,
            fly_modal_open: false,
            build_progress: Default::default(),
            running_apps: HashMap::new(),
            scroll: 0,
            term_height: 0,
            num_lines_with_wrapping: 0,
            anim_start: Instant::now(),
            tab: Tab::BuildLog,
        })
    }

    /// Wait for either the ctrl_c handler or the next event
    ///
    /// Why is the ctrl_c handler here?
    ///
    /// Also tick animations every few ms
    pub async fn wait(&mut self) -> io::Result<()> {
        // sorry lord
        let user_input = match self.events.as_mut() {
            Some(events) => {
                let pinned: Pin<Box<dyn Future<Output = Option<Result<Event, _>>>>> =
                    Box::pin(events.next());
                pinned
            }
            None => Box::pin(futures_util::future::pending()) as Pin<Box<dyn Future<Output = _>>>,
        };

        let has_running_apps = !self.running_apps.is_empty();
        let next_stdout = self.running_apps.values_mut().map(|app| {
            let future = async move {
                let (stdout, stderr) = match &mut app.stdout {
                    Some(stdout) => (stdout.stdout.next_line(), stdout.stderr.next_line()),
                    None => return futures_util::future::pending().await,
                };

                tokio::select! {
                    Ok(Some(line)) = stdout => (app.result.platform, Some(line), None),
                    Ok(Some(line)) = stderr => (app.result.platform, None, Some(line)),
                    else => futures_util::future::pending().await,
                }
            };
            Box::pin(future)
        });

        let next_stdout = async {

Review comment (suggestion):
In the future we should provide a comment as to what the boolean actually means - or communicate this through a different mechanism (enum, result/err, etc)

Code after:
            term: Rc::new(RefCell::new(term)),
            events,
            _rustc_version,
            _rustc_nightly,
            _dx_version: dx_version,
            interactive,
            is_cli_release,
            platform,
            fly_modal_open: false,
            build_progress: Default::default(),
            running_apps: HashMap::new(),
            scroll: 0,
            term_height: 0,
            num_lines_with_wrapping: 0,
            anim_start: Instant::now(),
            tab: Tab::BuildLog,
            addr: cfg.server_arguments.address.clone(),
        })
    }

    /// Wait for either the ctrl_c handler or the next event
    ///
    /// Why is the ctrl_c handler here?
    ///
    /// Also tick animations every few ms
    pub async fn wait(&mut self) -> io::Result<bool> {
        // sorry lord
        let user_input = match self.events.as_mut() {
            Some(events) => {
                let pinned: Pin<Box<dyn Future<Output = Option<Result<Event, _>>>>> =
                    Box::pin(events.next());
                pinned
            }
            None => Box::pin(futures_util::future::pending()) as Pin<Box<dyn Future<Output = _>>>,
        };

        let has_running_apps = !self.running_apps.is_empty();
        let next_stdout = self.running_apps.values_mut().map(|app| {
            let future = async move {
                let (stdout, stderr) = match &mut app.stdout {
                    Some(stdout) => (stdout.stdout.next_line(), stdout.stderr.next_line()),
                    None => return futures_util::future::pending().await,
                };

                tokio::select! {
                    Ok(Some(line)) = stdout => (app.result.platform, Some(line), None),
                    Ok(Some(line)) = stderr => (app.result.platform, None, Some(line)),
                    else => futures_util::future::pending().await,
                }
            };
            Box::pin(future)