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

Unwatch modification #15

Closed
jvonmitchell opened this issue Jun 18, 2014 · 4 comments
Closed

Unwatch modification #15

jvonmitchell opened this issue Jun 18, 2014 · 4 comments

Comments

@jvonmitchell
Copy link

Hi, on my system I'm doing a quick fix to allow for unwatching and figured you might be interested in what I'm doing. I'm just returning the fs.watch so the user can perform a close on that. We might as well have the function return something.

@yuanchuan
Copy link
Owner

That's nice, would like to see any modifications and improvements!

@jvonmitchell
Copy link
Author

I'm realizing it was already in my fork. There is no explicit mention of close in the source code but you can now say.

var watch = watchFile('somepath',somecallback);
...
watch.close();

Here's a review of what it does. jvonmitchell@22e5936#diff-481962e7a473d9939d95e86648f023ee

All it does is expose the underlying listener so that you can close it. If any one wants to build a better return object that's ok with me. The idea is that the call to watch was exposing nothing so we might as well make it something.

One flaw with the way it is done is that it may return a listener or a [] so you have to watch for that. That's why there is a good argument for a better return object.

PS, yuanchuan: I want to apologize for writing something that may seem out of context. Someone emailed me asking for the updated code. I thought those emails were sent to me from this issue. Hence the sillyness. Feel free to use the changes I made.

@jvonmitchell
Copy link
Author

Ok. I now have a branch that returns an instance of an internal class that we can define behaviors for our return object in. I implemented close. More things could be implemented.

The branch is called returnObject.

@vallettea
Copy link

👍

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

3 participants