rplevy / ojo

Simple and extensible framework for watching and handling file system events using the Java 7 Watch Service API.
40 stars 1 forks source link

ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.IFn #1

Closed klauern closed 11 years ago

klauern commented 11 years ago

In a simple ns I wrote up to try this out, I get an error I can't quite figure out where it's happening from. I took the copy/pasted example on the README and trie to work with it:

(ns watch
  (:require [ojo.watch]))

(def result (atom nil))

(ojo.watch/defwatch watcher
  ["C:/temp/watching" [["*"]]] [:create :modify]
  (let [[{:keys [file kind appended-only? bit-position] :as evt}]
        *events*]
    (reset! result
            (println file kind) 
            (format "%s%s"
                    (slurp file)
                    (if appended-only? "(append-only)" "")))))

And I get:

ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.IFn  useful.map/assoc-or (map.clj:21)
klauern commented 11 years ago

This is with the 1.1.0 version, fwiw.

rplevy-draker commented 11 years ago

Hi @klauern did you try starting with the provided example project? I haven't tried your code, but I see at least two problems with your code. 1. The settings hash-map that you have left out is not optional and 2. "C:.." is probably not supported, but a relative path will work.

Example project is in the example directory in ojo repo: https://github.com/drakerlabs/ojo/tree/master/example

klauern commented 11 years ago

Ah, silly me. Okay, I was able to get it to work now using this:

(ojo.watch/defwatch watcher
  ["C:/temp/watching" [["*"]]] [:create :modify]
  {}
  (let [[{:keys [file kind appended-only? bit-position] :as evt}]
        *events*]
    (println "event " file kind)))