(add-io-watch obj k f opts)registers the watch to a global list of filewatchers
registers the watch to a global list of *filewatchers*
(pattern s)creates a regex pattern from the string representation
(pattern ".*") => #"\Q.\E.+"
(pattern "*.jar") => #".+\Q.\Ejar"
creates a regex pattern from the string representation (pattern ".*") => #"\Q.\E.+" (pattern "*.jar") => #".+\Q.\Ejar"
(process-event watcher kind file)helper function to process event
helper function to process event
(register-entry service path)adds a path to the watch service
(-> (.newWatchService (FileSystems/getDefault)) (register-entry "src"))
adds a path to the watch service
(-> (.newWatchService (FileSystems/getDefault))
(register-entry "src"))(register-path {:keys [service] :as watcher} path)registers either a file or a path to the watcher (-> (watcher [] {} {}) (assoc :service (.newWatchService (FileSystems/getDefault))) (register-path "test"))
registers either a file or a path to the watcher
(-> (watcher [] {} {})
(assoc :service (.newWatchService (FileSystems/getDefault)))
(register-path "test"))(register-sub-directory watcher dir-path)registers a directory to an existing watcher
(-> (watcher ["src"] {} {}) (assoc :service (.newWatchService (FileSystems/getDefault))) (register-sub-directory "test"))
registers a directory to an existing watcher
(-> (watcher ["src"] {} {})
(assoc :service (.newWatchService (FileSystems/getDefault)))
(register-sub-directory "test"))(remove-io-watch obj k _)removes the watcher with the given key
removes the watcher with the given key
(run-watcher watcher)initiates the watcher with the given callbacks
initiates the watcher with the given callbacks
(watch-callback f root k)helper function to create watch callback
helper function to create watch callback
(watcher paths callback options)the watch interface provided for java.io.File
(def ^:dynamic happy (promise))
(watch/add (io/file ".") :save (fn [f k _ [cmd file]] (watch/remove f k) (.delete file) (deliver happy [cmd (.getName file)])) {:types #{:create :modify} :recursive false :filter [".hara"] :exclude [".git" "target"]})
(watch/list (io/file ".")) => (contains {:save fn?})
(spit "happy.hara" "hello")
@happy => [:create "happy.hara"]
(watch/list (io/file ".")) => {}
the watch interface provided for java.io.File
(def ^:dynamic *happy* (promise))
(watch/add (io/file ".") :save
(fn [f k _ [cmd file]]
(watch/remove f k)
(.delete file)
(deliver *happy* [cmd (.getName file)]))
{:types #{:create :modify}
:recursive false
:filter [".hara"]
:exclude [".git" "target"]})
(watch/list (io/file "."))
=> (contains {:save fn?})
(spit "happy.hara" "hello")
@*happy*
=> [:create "happy.hara"]
(watch/list (io/file "."))
=> {}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |