pub fn retrieve_matched_stories(&mut self) {
        let query = match self.get_search_text_view_mut() {
            None => return,
            Some(view) => view.get_text(),
        };
        let sender = self.sender.clone();
        let client = self.client.clone();
        let by_date = self.by_date;
        let page = self.page;

        // use a `cb_sink` to notify the `Cursive` renderer to re-draw the application
        // after successfully retrieving matched stories
        let cb_sink = self.cb_sink.clone();

        std::thread::spawn(
            move || match client.get_matched_stories(&query, by_date, page) {
                Ok(stories) => {
                    sender
                        .send(MatchedStories {
                            query,
                            stories,
                            by_date,
                            page,
                        })
                        .unwrap();
                    // send a dummy callback to `cb_sink`
                    cb_sink.send(Box::new(move |_| {})).unwrap();
                }
                Err(err) => {
                    warn!(
                        "failed to get matched stories (query={}, by_date={}, page={}): {}",
                        query, by_date, page, err
                    );
                }
            },
        );
    }
/// retrieves stories matching the current query by making an external (API) request
///
/// To ensure this function not blocking, message passing with channels is used.
retrieves stories matching the current query by making an external (API) request
To ensure this function not blocking, message passing with channels is used.
retrieves stories matching the current query by making an external ( API ) request To ensure this function not blocking message passing with channels is used .
pub fn retrieve_matched_stories(&mut self) {
        let query = match self.get_search_text_view_mut() {
            None => return,
            Some(view) => view.get_text(),
        };
        let sender = self.sender.clone();
        let client = self.client.clone();
        let by_date = self.by_date;
        let page = self.page;
        // use a `cb_sink` to notify the `Cursive` renderer to re-draw the application
        // after successfully retrieving matched stories
        let cb_sink = self.cb_sink.clone();
        std::thread::spawn(
            move || match client.get_matched_stories(&query, by_date, page) {
                Ok(stories) => {
                    sender
                        .send(MatchedStories {
                            query,
                            stories,
                            by_date,
                            page,
                        })
                        .unwrap();
                    // send a dummy callback to `cb_sink`
                    cb_sink.send(Box::new(move |_| {})).unwrap();
                }
                Err(err) => {
                    warn!(
                        "failed to get matched stories (query={}, by_date={}, page={}): {}",
                        query, by_date, page, err
                    );
                }
            },
        );
    }
pub fn retrieve_matched_stories ( & mut self ) { let query = match self . get_search_text_view_mut ( ) { None => return , Some ( view ) => view . get_text ( ) , } ; let sender = self . sender . clone ( ) ; let client = self . client . clone ( ) ; let by_date = self . by_date ; let page = self . page ; // use a `cb_sink` to notify the `Cursive` renderer to re-draw the application // after successfully retrieving matched stories let cb_sink = self . cb_sink . clone ( ) ; std :: thread :: spawn ( move | | match client . get_matched_stories ( & query , by_date , page ) { Ok ( stories ) => { sender . send ( MatchedStories { query , stories , by_date , page , } ) . unwrap ( ) ; // send a dummy callback to `cb_sink` cb_sink . send ( Box :: new ( move | _ | { } ) ) . unwrap ( ) ; } Err ( err ) => { warn ! ( " " query by_date page err ) ; } } , ) ; }
retrieves stories matching the current query by making an external (API) request
To ensure this function not blocking, message passing with channels is used.
retrieves stories matching the current query by making an external ( API ) request To ensure this function not blocking message passing with channels is used .
&mut self