Skip to content

ezand/watchdog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WatchDog

WatchDog is a Clojure library that lets you watch for directory- and file changes.

Build Status

Install

Leiningen

[watchdog "1.0.2"]

Maven

<dependency>
  <groupId>watchdog</groupId>
  <artifactId>watchdog</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

WatchDog has two main functions, watch and unwatch which registeres and unregisteres directories against the watch service.

Watching directories

(ns my.app
  (:require [watchdog.core])

  ;Function to handle the watch event. This will be called for all registered events.
  (defn- watch-callback [watch-event]
    (prn watch-event))

  ;Watch specified paths including all sub-folders. Listen for all change events.
  (watch ["/your/path" "/some/path"] :all watch-callback)

  ;Watch specified paths excluding all sub-folders. Listen for all change events.
  (watch ["/your/path" "/some/path"] false :all watch-callback))

View currently watched directories

;Return all currently watched directories
(watching)

Unwatch directories

;Unwatch specified paths including all sub-folders.
(unwatch ["/your/path"])

;Unwatch specified paths excluding all sub-folders.
(unwatch ["/your/path"] false)

Watch events

Available watch events are :create, :delete and :modify. To listen for all events, specify :all.

;Listen for all change events
(watch ["/your/path"] :all watch-callback)

;Listen for create and delete events only
(watch ["/your/path"] [:create :delete] watch-callback)

About

WatchDog is a Clojure library that lets you watch for directory- and file changes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published