pub fn start_html<Closure: Fn(&str) -> () + Copy>(listener: Arc<RwLock<FileListener>>, config: &PufferfishConfig, on_change: Closure) {
        let (tx_watcher, rx) = channel();
        let mut watcher_html = watcher(tx_watcher, Duration::from_secs(10)).unwrap();
        watcher_html.watch(config.html_dir(), RecursiveMode::Recursive).unwrap();
    
        loop {
            match rx.recv() {
                Ok(event) => {
                    let file = {
                        let mut _listener = listener.write().unwrap();
                        _listener.handle_event(event)
                    };
                    if let Some(file) = file {
                        on_change(&file);
                    }
                },
                Err(e) => eprintln!("File listener error: {:?}", e)
            }
        }
    }
// TODO: add closure that gets called on updates to be called to refresh the server
//       also for `start_templates`
/// Starts listening for file changes in html dir
add closure that gets called on updates to be called to refresh the server
also for `start_templates`
Starts listening for file changes in html dir
add closure that gets called on updates to be called to refresh the server also for ` start_templates ` Starts listening for file changes in html dir
pub fn start_html<Closure: Fn(&str) -> () + Copy>(listener: Arc<RwLock<FileListener>>, config: &PufferfishConfig, on_change: Closure) {
        let (tx_watcher, rx) = channel();
        let mut watcher_html = watcher(tx_watcher, Duration::from_secs(10)).unwrap();
        watcher_html.watch(config.html_dir(), RecursiveMode::Recursive).unwrap();
        loop {
            match rx.recv() {
                Ok(event) => {
                    let file = {
                        let mut _listener = listener.write().unwrap();
                        _listener.handle_event(event)
                    };
                    if let Some(file) = file {
                        on_change(&file);
                    }
                },
                Err(e) => eprintln!("File listener error: {:?}", e)
            }
        }
    }
pub fn start_html < Closure : Fn ( & str ) -> ( ) + Copy > ( listener : Arc < RwLock < FileListener > > , config : & PufferfishConfig , on_change : Closure ) { let ( tx_watcher , rx ) = channel ( ) ; let mut watcher_html = watcher ( tx_watcher , Duration :: from_secs ( 10 ) ) . unwrap ( ) ; watcher_html . watch ( config . html_dir ( ) , RecursiveMode :: Recursive ) . unwrap ( ) ; loop { match rx . recv ( ) { Ok ( event ) => { let file = { let mut _listener = listener . write ( ) . unwrap ( ) ; _listener . handle_event ( event ) } ; if let Some ( file ) = file { on_change ( & file ) ; } } , Err ( e ) => eprintln ! ( " " e ) } } }
TODO: add closure that gets called on updates to be called to refresh the server
also for `start_templates`
Starts listening for file changes in html dir
TODO : add closure that gets called on updates to be called to refresh the server also for ` start_templates ` Starts listening for file changes in html dir
listener
Arc<RwLock<FileListener>>
config
&PufferfishConfig
on_change
Closure
listener
Arc<RwLock<FileListener>>
config
&PufferfishConfig
on_change
Closure