federicoceratto / nim-fswatch Goto Github PK
View Code? Open in Web Editor NEWNim wrapper for the fswatch library
License: GNU General Public License v3.0
Nim wrapper for the fswatch library
License: GNU General Public License v3.0
Minimal reproduction:
import fswatch
var monitor = newMonitor(latency=0.01)
monitor.set_recursive true
monitor.add("test_files")
proc callback(eg: EventGroup) =
for e in eg:
echo "Event: ", e.kind
monitor.setCallback(callback)
monitor.start()
Create a folder containing some folders and run:
mkdir test_files
for i in `seq 10`; do mkdir "test_files/$i"; done
nim c -r test.nim
Yields this result:
Error: unhandled exception: index 101 not in 0 .. 100 [IndexError]
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)
. Its template/generic instantiation of `setCallback` from here
. And another, monitor.start()
gives the error Error: 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 in libsfwatch.nim
file to const 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!
setCallback assumes the existence of a data variable which is passed to the callback:
Line 110 in 60d5190
A temporary fix is to declare a variable named data in the scope where setCallback is called.
var data = ""
monitor.setCallback(callback)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.