Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X - template/generic instantiation of setCallback from here #1

Open
mikebelanger opened this issue Sep 11, 2019 · 3 comments
Open

Comments

@mikebelanger
Copy link

mikebelanger commented Sep 11, 2019

Hello!

Promising wrappers here! Unfortunately I can't quite get it to run, but maybe I'm doing it wrong.

  • Running Mac OS X (Darwin v. 10.13.6)
  • Installed fswatch with brew, ie) brew install fswatch.
  • Installed this library using nimble, ie) 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!

@jasonk000
Copy link

jasonk000 commented May 4, 2020

You need to create a data var in the same scope as which your monitor is started and the containers cb is present.

@mikebelanger
Copy link
Author

@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.

@mikebelanger
Copy link
Author

Better yet I created a PR to show what's worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants