-
Notifications
You must be signed in to change notification settings - Fork 356
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
Emit an event when gaze has finished setting up #332
base: main
Are you sure you want to change the base?
Conversation
👍 |
I think this will require more thought. Events don't work well with Grunt. You can't do much with an event besides logging so I think just logging a Also this implementation would fire the event for each target that is ready. I think it would be better to just log once when all watched targets are ready. |
I've corrected the improper placement of my event generation just in case, but I'd also be fine with moving the existing |
@shama Any thoughts on my response? I'd like to know for sure so that I can update my pull request. |
The location you moved the event still won't emit once all watchers are actually ready. You would need to track how many watchers we will be opening, then once all have stated they're ready, emit the event. Something like: var targetsCount = targets.length;
function watcherIsReady() {
targetsCount--;
// Only call when all watchers indicated they're ready
if (targetsCount < 1) self.emit('watch.ready');
}
watchers.push(new Gaze(patterns, target.options, function(err) {
// Call each time a watcher is ready
watcherIsReady();
})); But I still don't know if the event is a good route. People will abuse the event and open up issues about why scenario X doesn't work (it already happens way too much with the I just need to ask around more for more opinions on it. Thanks for being patient with me. |
Once all of the setup tasks required to react to changes on the file system are complete, emit an event.
Use case: When watching a large number of files it can take some time to glob for all of the requested files and make the inotify request. By watching for this event, a message can be written to the console after setup is complete and future changes will be detected.