Skip to content

'on' event callback signature #2

@alexyoung

Description

@alexyoung

Your example reads like this:

watcher.watch("C:\\myDir", function(err, watcher) {
    if(err) {
        console.log("ERROR: " + err);
    } else {
        console.log("DONE");
    }
});

When I try that (in Mac OS X) the callback doesn't follow the same signature. Whenever any change happens (file creation, deletion, change) the err value is a string set to rename, and the second parameter is the directory name, then the third parameter is the object for a Watcher.

This is the code I tried it with:

var treeWatcher = require('tree-watcher')
  , watcher;

watcher = new treeWatcher.Watcher({
  filter: function(filename) {
    return filename.charAt(0) !== '.';
  }
, throttle: 50
});

watcher.on('change', function(err, w) {
  console.log('change args:', arguments);
  if (err) {
    console.error('Error:', err);
  } else {
    console.log('Watcher state:', w);
  }
});

watcher.watch('/Users/alex/Desktop/watch', function() {
  console.log('Args:', arguments);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions