Skip to content

Commit

Permalink
examples: fix watcher_kind example to work with the changes from #396 (
Browse files Browse the repository at this point in the history
  • Loading branch information
jhscheer committed May 21, 2022
1 parent 6a9fb7a commit 0245625
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions examples/watcher_kind/src/main.rs
@@ -1,10 +1,14 @@
use std::time::Duration;

use notify::*;
use notify::{poll::PollWatcherConfig, *};
fn main() {
let (tx, rx) = std::sync::mpsc::channel();
let watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher {
Box::new(PollWatcher::with_delay(tx, Duration::from_secs(1)).unwrap())
let (tx, _rx) = std::sync::mpsc::channel();
let _watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher {
let config = PollWatcherConfig {
poll_interval: Duration::from_secs(1),
..Default::default()
};
Box::new(PollWatcher::with_config(tx, config).unwrap())
} else {
Box::new(RecommendedWatcher::new(tx).unwrap())
};
Expand Down
2 changes: 1 addition & 1 deletion src/poll.rs
Expand Up @@ -386,7 +386,7 @@ impl Watcher for PollWatcher {
/// Create a new [PollWatcher].
///
/// The default poll frequency is 30 seconds.
/// Use [with_delay] to manually set the poll frequency.
/// Use [with_config] to manually set the poll frequency.
fn new<F: EventHandler>(event_handler: F) -> Result<Self> {
Self::with_config(event_handler, PollWatcherConfig::default())
}
Expand Down

0 comments on commit 0245625

Please sign in to comment.