Open mikebelanger opened 4 years ago
You need to create a data
var in the same scope as which your monitor is started and the containers cb is present.
@jasonk000 ah thanks! I created a var globally in the example like
import times, fswatch
var data = ""
var monitor = newMonitor(latency=0.01)
monitor.add("/Users/mikebelanger/Dev/Personal/nim_filewatcher/some_file.txt")
proc callback(eg: EventGroup) =
for e in eg:
echo e.path, " ", $e.kind, " ", e.time.utc()
monitor.setCallback(callback)
# blocks here
monitor.start()
Should this go into the main example? Or is it so simple that most dev's would get this anyway?
Also, For any other mac (brew) users: changing the libfswatch.nim
's libfswatch_fn
to "/usr/local/Cellar/fswatch/1.14.0/lib/libfswatch.11.dylib"
was necessary as well.
Better yet I created a PR to show what's worked for me.
Hello!
Promising wrappers here! Unfortunately I can't quite get it to run, but maybe I'm doing it wrong.
brew install fswatch
.nimble install fswatch
.When I try running the example code, I get an error on line 5, the
monitor.setCallback(callback)
. Itstemplate/generic instantiation of `setCallback` from here
. And another,monitor.start()
gives the errorError: undeclared identifier: 'data'
. I'm guessing the first error is related to the first error though.Judging from this project's README, this has only been tested on Linux. So I changed the library's
libfswatch_fn
variable inlibsfwatch.nim
file toconst libfswatch_fn* = "/usr/local/Cellar/fswatch/1.14.0/lib/libfswatch.11.dylib"
, which is the path to my lib on os x. But I still get the same error after changing this.If I'm just doing something plain wrong, please let me know and close the issue. Thanks!