pub fn start_templates<Closure: Fn(&str) -> () + Copy>(listener: Arc<RwLock<FileListener>>, config: &PufferfishConfig, on_change: Closure) {
        let (tx_watcher, rx) = channel();
        let mut watcher_templates = watcher(tx_watcher, Duration::from_secs(10)).unwrap();
        watcher_templates.watch(config.template_dir(), RecursiveMode::Recursive).unwrap();
        
        loop {
            match rx.recv() {
                Ok(event) => {
                    let file = {
                       listener.write().unwrap().handle_event(event)
                    };
                    if let Some(file) = file {
                        on_change(&file);
                    }
                }
                Err(e) => eprintln!("File listener error: {:?}", e)
            }
        }
    }
/// Starts listening for file changes in templates dir
Starts listening for file changes in templates dir
Starts listening for file changes in templates dir
pub fn start_templates<Closure: Fn(&str) -> () + Copy>(listener: Arc<RwLock<FileListener>>, config: &PufferfishConfig, on_change: Closure) {
        let (tx_watcher, rx) = channel();
        let mut watcher_templates = watcher(tx_watcher, Duration::from_secs(10)).unwrap();
        watcher_templates.watch(config.template_dir(), RecursiveMode::Recursive).unwrap();
        loop {
            match rx.recv() {
                Ok(event) => {
                    let file = {
                       listener.write().unwrap().handle_event(event)
                    };
                    if let Some(file) = file {
                        on_change(&file);
                    }
                }
                Err(e) => eprintln!("File listener error: {:?}", e)
            }
        }
    }
pub fn start_templates < Closure : Fn ( & str ) -> ( ) + Copy > ( listener : Arc < RwLock < FileListener > > , config : & PufferfishConfig , on_change : Closure ) { let ( tx_watcher , rx ) = channel ( ) ; let mut watcher_templates = watcher ( tx_watcher , Duration :: from_secs ( 10 ) ) . unwrap ( ) ; watcher_templates . watch ( config . template_dir ( ) , RecursiveMode :: Recursive ) . unwrap ( ) ; loop { match rx . recv ( ) { Ok ( event ) => { let file = { listener . write ( ) . unwrap ( ) . handle_event ( event ) } ; if let Some ( file ) = file { on_change ( & file ) ; } } Err ( e ) => eprintln ! ( " " e ) } } }
Starts listening for file changes in templates dir
Starts listening for file changes in templates dir
listener
Arc<RwLock<FileListener>>
config
&PufferfishConfig
on_change
Closure
listener
Arc<RwLock<FileListener>>
config
&PufferfishConfig
on_change
Closure